##// END OF EJS Templates
null template
Matthias BUSSONNIER -
Show More
@@ -0,0 +1,61 b''
1 {%- extends 'basic.tpl' -%}
2
3
4
5
6 {% block codecell scoped %}
7 <div class="cell border-box-sizing code_cell vbox">
8 <div class="input hbox">
9 <div class="prompt input_prompt">In&nbsp;[{{cell.prompt_number if cell.prompt_number else '&nbsp;'}}]:</div>
10 <div class="input_area box-flex1">
11 {{ cell.input|highlight -}}
12 </div>
13 </div>
14 {% if cell.outputs %}
15 {%- for output in cell.outputs -%}
16 <div class="vbox output_wrapper">
17 <div class="output vbox">
18 <div class="hbox output_area">
19 <div class="prompt output_prompt"></div>
20 {%- if output.output_type in ['pyout','stream'] %}
21 <div class="output_subarea output_stream output_stdout">
22 <pre>{{ output.text }}</pre>
23 </div>
24 </div>
25 </div>
26 {%- elif output.output_type in ['display_data'] %}
27 <div class="output_subarea output_display_data">
28 {{"# image file: fucking display_data"}}
29 </div>
30 {%- elif output.output_type in ['pyerr'] %}
31 {%- for line in output.traceback %}
32 {{ line |indent| rm_ansi}}
33 {%- endfor %}
34 {%- endif %}
35 {%- endfor -%}
36 {% endif %}
37 </div>
38 </div>
39 {% endblock codecell %}
40
41 {% block markdowncell scoped -%}
42 <div class="text_cell_render border-box-sizing rendered_html">
43 {{ cell.source | markdown| rm_fake}}
44 </div>
45 {%- endblock markdowncell %}
46
47 {% block headingcell scoped %}
48 <div class="text_cell_render border-box-sizing rendered_html">
49 <h{{cell.level}}>
50 {{cell.source}}
51 </h{{cell.level}}>
52 </div>
53 {% endblock headingcell %}
54
55 {% block rawcell scoped %}
56 {{ cell.source | pycomment }}
57 {% endblock rawcell %}
58
59 {% block unknowncell scoped %}
60 unknown type {{cell.type}}
61 {% endblock unknowncell %}
This diff has been collapsed as it changes many lines, (787 lines changed) Show them Hide them
@@ -0,0 +1,787 b''
1 {%- extends 'basichtml.tpl' -%}
2
3 {%- block header -%}
4 <html>
5 <head>
6 <style type="text/css">
7 /**
8 * HTML5 Boilerplate
9 *
10 * style.css contains a reset, font normalization and some base styles.
11 *
12 * Credit is left where credit is due.
13 * Much inspiration was taken from these projects:
14 * - yui.yahooapis.com/2.8.1/build/base/base.css
15 * - camendesign.com/design/
16 * - praegnanz.de/weblog/htmlcssjs-kickstart
17 */
18
19
20 /**
21 * html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline)
22 * v1.6.1 2010-09-17 | Authors: Eric Meyer & Richard Clark
23 * html5doctor.com/html-5-reset-stylesheet/
24 */
25
26 html, body, div, span, object, iframe,
27 h1, h2, h3, h4, h5, h6, p, blockquote, pre,
28 abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
29 small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
30 fieldset, form, label, legend,
31 table, caption, tbody, tfoot, thead, tr, th, td,
32 article, aside, canvas, details, figcaption, figure,
33 footer, header, hgroup, menu, nav, section, summary,
34 time, mark, audio, video {
35 margin: 0;
36 padding: 0;
37 border: 0;
38 font-size: 100%;
39 font: inherit;
40 vertical-align: baseline;
41 }
42
43 sup { vertical-align: super; }
44 sub { vertical-align: sub; }
45
46 article, aside, details, figcaption, figure,
47 footer, header, hgroup, menu, nav, section {
48 display: block;
49 }
50
51 blockquote, q { quotes: none; }
52
53 blockquote:before, blockquote:after,
54 q:before, q:after { content: ""; content: none; }
55
56 ins { background-color: #ff9; color: #000; text-decoration: none; }
57
58 mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; }
59
60 del { text-decoration: line-through; }
61
62 abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; }
63
64 table { border-collapse: collapse; border-spacing: 0; }
65
66 hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
67
68 input, select { vertical-align: middle; }
69
70
71 /**
72 * Font normalization inspired by YUI Library's fonts.css: developer.yahoo.com/yui/
73 */
74
75 body { font:13px/1.231 sans-serif; *font-size:small; } /* Hack retained to preserve specificity */
76 select, input, textarea, button { font:99% sans-serif; }
77
78 /* Normalize monospace sizing:
79 en.wikipedia.org/wiki/MediaWiki_talk:Common.css/Archive_11#Teletype_style_fix_for_Chrome */
80 pre, code, kbd, samp { font-family: monospace, sans-serif; }
81
82 em,i { font-style: italic; }
83 b,strong { font-weight: bold; }
84
85 </style>
86 <style type="text/css">
87
88 /* Flexible box model classes */
89 /* Taken from Alex Russell http://infrequently.org/2009/08/css-3-progress/ */
90
91 .hbox {
92 display: -webkit-box;
93 -webkit-box-orient: horizontal;
94 -webkit-box-align: stretch;
95
96 display: -moz-box;
97 -moz-box-orient: horizontal;
98 -moz-box-align: stretch;
99
100 display: box;
101 box-orient: horizontal;
102 box-align: stretch;
103 }
104
105 .hbox > * {
106 -webkit-box-flex: 0;
107 -moz-box-flex: 0;
108 box-flex: 0;
109 }
110
111 .vbox {
112 display: -webkit-box;
113 -webkit-box-orient: vertical;
114 -webkit-box-align: stretch;
115
116 display: -moz-box;
117 -moz-box-orient: vertical;
118 -moz-box-align: stretch;
119
120 display: box;
121 box-orient: vertical;
122 box-align: stretch;
123 }
124
125 .vbox > * {
126 -webkit-box-flex: 0;
127 -moz-box-flex: 0;
128 box-flex: 0;
129 }
130
131 .reverse {
132 -webkit-box-direction: reverse;
133 -moz-box-direction: reverse;
134 box-direction: reverse;
135 }
136
137 .box-flex0 {
138 -webkit-box-flex: 0;
139 -moz-box-flex: 0;
140 box-flex: 0;
141 }
142
143 .box-flex1, .box-flex {
144 -webkit-box-flex: 1;
145 -moz-box-flex: 1;
146 box-flex: 1;
147 }
148
149 .box-flex2 {
150 -webkit-box-flex: 2;
151 -moz-box-flex: 2;
152 box-flex: 2;
153 }
154
155 .box-group1 {
156 -webkit-box-flex-group: 1;
157 -moz-box-flex-group: 1;
158 box-flex-group: 1;
159 }
160
161 .box-group2 {
162 -webkit-box-flex-group: 2;
163 -moz-box-flex-group: 2;
164 box-flex-group: 2;
165 }
166
167 .start {
168 -webkit-box-pack: start;
169 -moz-box-pack: start;
170 box-pack: start;
171 }
172
173 .end {
174 -webkit-box-pack: end;
175 -moz-box-pack: end;
176 box-pack: end;
177 }
178
179 .center {
180 -webkit-box-pack: center;
181 -moz-box-pack: center;
182 box-pack: center;
183 }
184
185 </style>
186 <style type="text/css">
187 /**
188 * Primary styles
189 *
190 * Author: IPython Development Team
191 */
192
193
194 body {
195 overflow: hidden;
196 }
197
198 blockquote {
199 border-left: 4px solid #DDD;
200 padding: 0 15px;
201 color: #777;
202 }
203
204 span#save_widget {
205 padding: 5px;
206 margin: 0px 0px 0px 300px;
207 display:inline-block;
208 }
209
210 span#notebook_name {
211 height: 1em;
212 line-height: 1em;
213 padding: 3px;
214 border: none;
215 font-size: 146.5%;
216 }
217
218 .ui-menubar-item .ui-button .ui-button-text {
219 padding: 0.4em 1.0em;
220 font-size: 100%;
221 }
222
223 .ui-menu {
224 -moz-box-shadow: 0px 6px 10px -1px #adadad;
225 -webkit-box-shadow: 0px 6px 10px -1px #adadad;
226 box-shadow: 0px 6px 10px -1px #adadad;
227 }
228
229 .ui-menu .ui-menu-item a {
230 border: 1px solid transparent;
231 padding: 2px 1.6em;
232 }
233
234 .ui-menu .ui-menu-item a.ui-state-focus {
235 margin: 0;
236 }
237
238 .ui-menu hr {
239 margin: 0.3em 0;
240 }
241
242 #menubar_container {
243 position: relative;
244 }
245
246 #notification_area {
247 position: absolute;
248 right: 0px;
249 top: 0px;
250 height: 25px;
251 padding: 3px 0px;
252 padding-right: 3px;
253 z-index: 10;
254 }
255
256 .notification_widget{
257 float : right;
258 right: 0px;
259 top: 1px;
260 height: 25px;
261 padding: 3px 6px;
262 z-index: 10;
263 }
264
265 .toolbar {
266 padding: 3px 15px;
267 }
268
269 #cell_type {
270 font-size: 85%;
271 }
272
273
274 div#main_app {
275 width: 100%;
276 position: relative;
277 }
278
279 span#quick_help_area {
280 position: static;
281 padding: 5px 0px;
282 margin: 0px 0px 0px 0px;
283 }
284
285 .help_string {
286 float: right;
287 width: 170px;
288 padding: 0px 5px;
289 text-align: left;
290 font-size: 85%;
291 }
292
293 .help_string_label {
294 float: right;
295 font-size: 85%;
296 }
297
298 div#notebook_panel {
299 margin: 0px 0px 0px 0px;
300 padding: 0px;
301 }
302
303 div#notebook {
304 overflow-y: scroll;
305 overflow-x: auto;
306 width: 100%;
307 /* This spaces the cell away from the edge of the notebook area */
308 padding: 5px 5px 15px 5px;
309 margin: 0px;
310 background-color: white;
311 }
312
313 div#pager_splitter {
314 height: 8px;
315 }
316
317 #pager_container {
318 position : relative;
319 }
320
321 div#pager {
322 padding: 15px;
323 overflow: auto;
324 display: none;
325 }
326
327 div.ui-widget-content {
328 border: 1px solid #aaa;
329 outline: none;
330 }
331
332 .cell {
333 border: 1px solid transparent;
334 }
335
336 div.cell {
337 width: 100%;
338 padding: 5px 5px 5px 0px;
339 /* This acts as a spacer between cells, that is outside the border */
340 margin: 2px 0px 2px 0px;
341 }
342
343 div.code_cell {
344 background-color: white;
345 }
346
347 /* any special styling for code cells that are currently running goes here */
348 div.code_cell.running {
349 }
350
351 div.prompt {
352 /* This needs to be wide enough for 3 digit prompt numbers: In[100]: */
353 width: 11ex;
354 /* This 0.4em is tuned to match the padding on the CodeMirror editor. */
355 padding: 0.4em;
356 margin: 0px;
357 font-family: monospace;
358 text-align:right;
359 }
360
361 div.input {
362 page-break-inside: avoid;
363 }
364
365 /* input_area and input_prompt must match in top border and margin for alignment */
366 div.input_area {
367 color: black;
368 border: 1px solid #ddd;
369 border-radius: 3px;
370 background: #f7f7f7;
371 }
372
373 div.input_prompt {
374 color: navy;
375 border-top: 1px solid transparent;
376 }
377
378 div.output_wrapper {
379 /* This is a spacer between the input and output of each cell */
380 margin-top: 5px;
381 margin-left: 5px;
382 /* FF needs explicit width to stretch */
383 width: 100%;
384 /* this position must be relative to enable descendents to be absolute within it */
385 position: relative;
386 }
387
388 /* class for the output area when it should be height-limited */
389 div.output_scroll {
390 /* ideally, this would be max-height, but FF barfs all over that */
391 height: 24em;
392 /* FF needs this *and the wrapper* to specify full width, or it will shrinkwrap */
393 width: 100%;
394
395 overflow: auto;
396 border-radius: 3px;
397 box-shadow: inset 0 2px 8px rgba(0, 0, 0, .8);
398 }
399
400 /* output div while it is collapsed */
401 div.output_collapsed {
402 margin-right: 5px;
403 }
404
405 div.out_prompt_overlay {
406 height: 100%;
407 padding: 0px;
408 position: absolute;
409 border-radius: 3px;
410 }
411
412 div.out_prompt_overlay:hover {
413 /* use inner shadow to get border that is computed the same on WebKit/FF */
414 box-shadow: inset 0 0 1px #000;
415 background: rgba(240, 240, 240, 0.5);
416 }
417
418 div.output_prompt {
419 color: darkred;
420 /* 5px right shift to account for margin in parent container */
421 margin: 0 5px 0 -5px;
422 }
423
424 /* This class is the outer container of all output sections. */
425 div.output_area {
426 padding: 0px;
427 page-break-inside: avoid;
428 }
429
430 /* This class is for the output subarea inside the output_area and after
431 the prompt div. */
432 div.output_subarea {
433 padding: 0.44em 0.4em 0.4em 1px;
434 }
435
436 /* The rest of the output_* classes are for special styling of the different
437 output types */
438
439 /* all text output has this class: */
440 div.output_text {
441 text-align: left;
442 color: black;
443 font-family: monospace;
444 }
445
446 /* stdout/stderr are 'text' as well as 'stream', but pyout/pyerr are *not* streams */
447 div.output_stream {
448 padding-top: 0.0em;
449 padding-bottom: 0.0em;
450 }
451 div.output_stdout {
452 }
453 div.output_stderr {
454 background: #fdd; /* very light red background for stderr */
455 }
456
457 div.output_latex {
458 text-align: left;
459 color: black;
460 }
461
462 div.output_html {
463 }
464
465 div.output_png {
466 }
467
468 div.output_jpeg {
469 }
470
471 div.text_cell {
472 background-color: white;
473 padding: 5px 5px 5px 5px;
474 }
475
476 div.text_cell_input {
477 color: black;
478 border: 1px solid #ddd;
479 border-radius: 3px;
480 background: #f7f7f7;
481 }
482
483 div.text_cell_render {
484 font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
485 outline: none;
486 resize: none;
487 width: inherit;
488 border-style: none;
489 padding: 5px;
490 color: black;
491 }
492
493 /* The following gets added to the <head> if it is detected that the user has a
494 * monospace font with inconsistent normal/bold/italic height. See
495 * notebookmain.js. Such fonts will have keywords vertically offset with
496 * respect to the rest of the text. The user should select a better font.
497 * See: https://github.com/ipython/ipython/issues/1503
498 *
499 * .CodeMirror span {
500 * vertical-align: bottom;
501 * }
502 */
503
504 .CodeMirror {
505 line-height: 1.231; /* Changed from 1em to our global default */
506 }
507
508 .CodeMirror-scroll {
509 height: auto; /* Changed to auto to autogrow */
510 /* The CodeMirror docs are a bit fuzzy on if overflow-y should be hidden or visible.*/
511 /* We have found that if it is visible, vertical scrollbars appear with font size changes.*/
512 overflow-y: hidden;
513 overflow-x: auto; /* Changed from auto to remove scrollbar */
514 }
515
516 /* CSS font colors for translated ANSI colors. */
517
518
519 .ansiblack {color: black;}
520 .ansired {color: darkred;}
521 .ansigreen {color: darkgreen;}
522 .ansiyellow {color: brown;}
523 .ansiblue {color: darkblue;}
524 .ansipurple {color: darkviolet;}
525 .ansicyan {color: steelblue;}
526 .ansigrey {color: grey;}
527 .ansibold {font-weight: bold;}
528
529 .completions {
530 position: absolute;
531 z-index: 10;
532 overflow: hidden;
533 border: 1px solid grey;
534 }
535
536 .completions select {
537 background: white;
538 outline: none;
539 border: none;
540 padding: 0px;
541 margin: 0px;
542 overflow: auto;
543 font-family: monospace;
544 }
545
546 option.context {
547 background-color: #DEF7FF;
548 }
549 option.introspection {
550 background-color: #EBF4EB;
551 }
552
553 /*fixed part of the completion*/
554 .completions p b {
555 font-weight:bold;
556 }
557
558 .completions p {
559 background: #DDF;
560 /*outline: none;
561 padding: 0px;*/
562 border-bottom: black solid 1px;
563 padding: 1px;
564 font-family: monospace;
565 }
566
567 pre.dialog {
568 background-color: #f7f7f7;
569 border: 1px solid #ddd;
570 border-radius: 3px;
571 padding: 0.4em;
572 padding-left: 2em;
573 }
574
575 p.dialog {
576 padding : 0.2em;
577 }
578
579 .shortcut_key {
580 display: inline-block;
581 width: 15ex;
582 text-align: right;
583 font-family: monospace;
584 }
585
586 .shortcut_descr {
587 }
588
589 /* Word-wrap output correctly. This is the CSS3 spelling, though Firefox seems
590 to not honor it correctly. Webkit browsers (Chrome, rekonq, Safari) do.
591 */
592 pre, code, kbd, samp { white-space: pre-wrap; }
593
594 #fonttest {
595 font-family: monospace;
596 }
597
598 .js-error {
599 color: darkred;
600 }
601
602 </style>
603 <style type="text/css">
604 .rendered_html {color: black;}
605 .rendered_html em {font-style: italic;}
606 .rendered_html strong {font-weight: bold;}
607 .rendered_html u {text-decoration: underline;}
608 .rendered_html :link { text-decoration: underline }
609 .rendered_html :visited { text-decoration: underline }
610 .rendered_html h1 {font-size: 197%; margin: .65em 0; font-weight: bold;}
611 .rendered_html h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;}
612 .rendered_html h3 {font-size: 123.1%; margin: .85em 0; font-weight: bold;}
613 .rendered_html h4 {font-size: 100% margin: 0.95em 0; font-weight: bold;}
614 .rendered_html h5 {font-size: 85%; margin: 1.5em 0; font-weight: bold;}
615 .rendered_html h6 {font-size: 77%; margin: 1.65em 0; font-weight: bold;}
616 .rendered_html ul {list-style:disc; margin: 1em 2em;}
617 .rendered_html ul ul {list-style:square; margin: 0em 2em;}
618 .rendered_html ul ul ul {list-style:circle; margin-left: 0em 2em;}
619 .rendered_html ol {list-style:upper-roman; margin: 1em 2em;}
620 .rendered_html ol ol {list-style:upper-alpha; margin: 0em 2em;}
621 .rendered_html ol ol ol {list-style:decimal; margin: 0em 2em;}
622 .rendered_html ol ol ol ol {list-style:lower-alpha; margin: 0em 2em;}
623 .rendered_html ol ol ol ol ol {list-style:lower-roman; margin: 0em 2em;}
624
625 .rendered_html hr {
626 color: black;
627 background-color: black;
628 }
629
630 .rendered_html pre {
631 margin: 1em 2em;
632 }
633
634 .rendered_html blockquote {
635 margin: 1em 2em;
636 }
637
638 .rendered_html table {
639 border: 1px solid black;
640 border-collapse: collapse;
641 margin: 1em 2em;
642 }
643
644 .rendered_html td {
645 border: 1px solid black;
646 text-align: left;
647 vertical-align: middle;
648 padding: 4px;
649 }
650
651 .rendered_html th {
652 border: 1px solid black;
653 text-align: left;
654 vertical-align: middle;
655 padding: 4px;
656 font-weight: bold;
657 }
658
659 .rendered_html tr {
660 border: 1px solid black;
661 }
662
663 .rendered_html p + p {
664 margin-top: 1em;
665 }
666
667
668 </style>
669 <style type="text/css">
670 /* Overrides of notebook CSS for static HTML export
671
672 */
673 body {
674 overflow: visible;
675 padding: 8px;
676 }
677 .input_area {
678 padding: 0.4em;
679 }
680
681 </style>
682 <meta charset="UTF-8">
683 <style type="text/css">
684 .highlight .hll { background-color: #ffffcc }
685 .highlight { background: #f8f8f8; }
686 .highlight .c { color: #408080; font-style: italic } /* Comment */
687 .highlight .err { border: 1px solid #FF0000 } /* Error */
688 .highlight .k { color: #008000; font-weight: bold } /* Keyword */
689 .highlight .o { color: #666666 } /* Operator */
690 .highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
691 .highlight .cp { color: #BC7A00 } /* Comment.Preproc */
692 .highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
693 .highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
694 .highlight .gd { color: #A00000 } /* Generic.Deleted */
695 .highlight .ge { font-style: italic } /* Generic.Emph */
696 .highlight .gr { color: #FF0000 } /* Generic.Error */
697 .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
698 .highlight .gi { color: #00A000 } /* Generic.Inserted */
699 .highlight .go { color: #808080 } /* Generic.Output */
700 .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
701 .highlight .gs { font-weight: bold } /* Generic.Strong */
702 .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
703 .highlight .gt { color: #0040D0 } /* Generic.Traceback */
704 .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
705 .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
706 .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
707 .highlight .kp { color: #008000 } /* Keyword.Pseudo */
708 .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
709 .highlight .kt { color: #B00040 } /* Keyword.Type */
710 .highlight .m { color: #666666 } /* Literal.Number */
711 .highlight .s { color: #BA2121 } /* Literal.String */
712 .highlight .na { color: #7D9029 } /* Name.Attribute */
713 .highlight .nb { color: #008000 } /* Name.Builtin */
714 .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
715 .highlight .no { color: #880000 } /* Name.Constant */
716 .highlight .nd { color: #AA22FF } /* Name.Decorator */
717 .highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
718 .highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
719 .highlight .nf { color: #0000FF } /* Name.Function */
720 .highlight .nl { color: #A0A000 } /* Name.Label */
721 .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
722 .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
723 .highlight .nv { color: #19177C } /* Name.Variable */
724 .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
725 .highlight .w { color: #bbbbbb } /* Text.Whitespace */
726 .highlight .mf { color: #666666 } /* Literal.Number.Float */
727 .highlight .mh { color: #666666 } /* Literal.Number.Hex */
728 .highlight .mi { color: #666666 } /* Literal.Number.Integer */
729 .highlight .mo { color: #666666 } /* Literal.Number.Oct */
730 .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
731 .highlight .sc { color: #BA2121 } /* Literal.String.Char */
732 .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
733 .highlight .s2 { color: #BA2121 } /* Literal.String.Double */
734 .highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
735 .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
736 .highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
737 .highlight .sx { color: #008000 } /* Literal.String.Other */
738 .highlight .sr { color: #BB6688 } /* Literal.String.Regex */
739 .highlight .s1 { color: #BA2121 } /* Literal.String.Single */
740 .highlight .ss { color: #19177C } /* Literal.String.Symbol */
741 .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
742 .highlight .vc { color: #19177C } /* Name.Variable.Class */
743 .highlight .vg { color: #19177C } /* Name.Variable.Global */
744 .highlight .vi { color: #19177C } /* Name.Variable.Instance */
745 .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
746 </style>
747 <script src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript">
748
749 </script>
750 <script type="text/javascript">
751 init_mathjax = function() {
752 if (window.MathJax) {
753 // MathJax loaded
754 MathJax.Hub.Config({
755 tex2jax: {
756 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
757 displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
758 },
759 displayAlign: 'left', // Change this to 'center' to center equations.
760 "HTML-CSS": {
761 styles: {'.MathJax_Display': {"margin": 0}}
762 }
763 });
764 MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
765 }
766 }
767 init_mathjax();
768 </script>
769 </head>
770 {%- endblock header -%}
771
772
773 {% block body %}
774 <body>{{ super() }}<body/>
775
776 {% endblock body %}
777
778
779
780
781
782
783
784
785 {% block footer %}
786 </html>
787 {% endblock footer %}
@@ -0,0 +1,38 b''
1 {%- extends 'basic.tpl' -%}
2
3 {% block codecell scoped %}
4 {% block in_prompt %}{% endblock in_prompt %}
5 {% block input %}{% endblock input %}
6 {% if cell.outputs %}
7 {% block output_prompt %}{% endblock output_prompt %}
8 {%- for output in cell.outputs -%}
9 {%- if output.output_type in ['pyout']%}
10 {% block pyout scoped %}{% endblock pyout %}
11 {%- elif output.output_type in ['stream'] %}
12 {% block stream scoped %}{% endblock stream %}
13 {%- elif output.output_type in ['display_data'] %}
14 {% block display_data scoped %}{% endblock display_data %}
15 {%- elif output.output_type in ['pyerr'] %}
16 {% block pyerr scoped %}
17 {%- for line in output.traceback %}
18 {% block traceback_line scoped %}
19 {% endblock traceback_line %}
20 {%- endfor %}
21 {% endblock pyerr %}
22 {%- endif %}
23 {%- endfor -%}
24 {% endif %}
25
26 {% endblock codecell %}
27
28 {% block markdowncell scoped %}
29 {% endblock markdowncell %}
30
31 {% block headingcell scoped %}
32 {% endblock headingcell %}
33
34 {% block rawcell scoped %}
35 {% endblock rawcell %}
36
37 {% block unknowncell scoped %}
38 {% endblock unknowncell %}
@@ -1,103 +1,107 b''
1 """Base classes for the notebook conversion pipeline.
1 """Base classes for the notebook conversion pipeline.
2
2
3 This module defines Converter, from which all objects designed to implement
3 This module defines Converter, from which all objects designed to implement
4 a conversion of IPython notebooks to some other format should inherit.
4 a conversion of IPython notebooks to some other format should inherit.
5 """
5 """
6 #-----------------------------------------------------------------------------
6 #-----------------------------------------------------------------------------
7 # Copyright (c) 2012, the IPython Development Team.
7 # Copyright (c) 2012, the IPython Development Team.
8 #
8 #
9 # Distributed under the terms of the Modified BSD License.
9 # Distributed under the terms of the Modified BSD License.
10 #
10 #
11 # The full license is in the file COPYING.txt, distributed with this software.
11 # The full license is in the file COPYING.txt, distributed with this software.
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 from __future__ import print_function, absolute_import
18 from __future__ import print_function, absolute_import
19
19
20 # Stdlib imports
20 # Stdlib imports
21 import jinja2
21 import jinja2
22 import codecs
22 import codecs
23 import io
23 import io
24 import logging
24 import logging
25 import os
25 import os
26 import pprint
26 import pprint
27 import re
27 import re
28 from types import FunctionType
28 from types import FunctionType
29
29
30 from jinja2 import Environment, PackageLoader, FileSystemLoader
30 from jinja2 import Environment, PackageLoader, FileSystemLoader
31 env = Environment(loader=FileSystemLoader('./templates/'))
31 env = Environment(loader=FileSystemLoader('./templates/'))
32
32
33 # IPython imports
33 # IPython imports
34 from IPython.nbformat import current as nbformat
34 from IPython.nbformat import current as nbformat
35 from IPython.config.configurable import Configurable, SingletonConfigurable
35 from IPython.config.configurable import Configurable, SingletonConfigurable
36 from IPython.utils.traitlets import (List, Unicode, Type, Bool, Dict, CaselessStrEnum,
36 from IPython.utils.traitlets import (List, Unicode, Type, Bool, Dict, CaselessStrEnum,
37 Any)
37 Any)
38
38
39 # Our own imports
39 # Our own imports
40 from IPython.utils.text import indent
40 from IPython.utils.text import indent
41 from .utils import remove_ansi
41 from .utils import remove_ansi
42 from markdown import markdown
43 from .utils import highlight
42 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
43 # Class declarations
45 # Class declarations
44 #-----------------------------------------------------------------------------
46 #-----------------------------------------------------------------------------
45 def rm_fake(strng):
47 def rm_fake(strng):
46 return strng.replace('/files/', '')
48 return strng.replace('/files/', '')
47
49
48 class ConversionException(Exception):
50 class ConversionException(Exception):
49 pass
51 pass
50
52
51
53
52 def python_comment(string):
54 def python_comment(string):
53 return '# '+'\n# '.join(string.split('\n'))
55 return '# '+'\n# '.join(string.split('\n'))
54
56
55 env.filters['pycomment'] = python_comment
57 env.filters['pycomment'] = python_comment
56 env.filters['indent'] = indent
58 env.filters['indent'] = indent
57 env.filters['rm_fake'] = rm_fake
59 env.filters['rm_fake'] = rm_fake
58 env.filters['rm_ansi'] = remove_ansi
60 env.filters['rm_ansi'] = remove_ansi
61 env.filters['markdown'] = markdown
62 env.filters['highlight'] = highlight
59
63
60 class ConverterTemplate(Configurable):
64 class ConverterTemplate(Configurable):
61
65
62 display_data_priority = ['pdf', 'svg', 'png', 'jpg', 'text']
66 display_data_priority = ['pdf', 'svg', 'png', 'jpg', 'text']
63 #-------------------------------------------------------------------------
67 #-------------------------------------------------------------------------
64 # Instance-level attributes that are set in the constructor for this
68 # Instance-level attributes that are set in the constructor for this
65 # class.
69 # class.
66 #-------------------------------------------------------------------------
70 #-------------------------------------------------------------------------
67 infile = Any()
71 infile = Any()
68
72
69
73
70 infile_dir = Unicode()
74 infile_dir = Unicode()
71
75
72 def __init__(self, config=None, **kw):
76 def __init__(self, tplfile='fullhtml', config=None, **kw):
73 self.template = env.get_template('python.tpl')
77 self.template = env.get_template(tplfile+'.tpl')
74 super(ConverterTemplate,self).__init__(config=config)
78 super(ConverterTemplate,self).__init__(config=config)
75
79
76 def _get_prompt_number(self, cell):
80 def _get_prompt_number(self, cell):
77 return cell.prompt_number if hasattr(cell, 'prompt_number') \
81 return cell.prompt_number if hasattr(cell, 'prompt_number') \
78 else self.blank_symbol
82 else self.blank_symbol
79
83
80
84
81 def process(self):
85 def process(self):
82 converted_cells = []
86 converted_cells = []
83 for worksheet in self.nb.worksheets:
87 for worksheet in self.nb.worksheets:
84 for cell in worksheet.cells:
88 for cell in worksheet.cells:
85 cell.type = cell.cell_type
89 cell.type = cell.cell_type
86 converted_cells.append(cell)
90 converted_cells.append(cell)
87 continue
91 continue
88 if cell.cell_type in ('code'):
92 if cell.cell_type in ('code'):
89 converted_cells.append({'type':'code','source':cell.input})
93 converted_cells.append({'type':'code','source':cell.input})
90 else :
94 else :
91 converted_cells.append({'type':cell.cell_type,'source': python_comment(cell.source)})
95 converted_cells.append({'type':cell.cell_type,'source': python_comment(cell.source)})
92
96
93 return converted_cells
97 return converted_cells
94
98
95 def convert(self, cell_separator='\n'):
99 def convert(self, cell_separator='\n'):
96 return self.template.render(cells=self.process())
100 return self.template.render(cells=self.process())
97
101
98
102
99 def read(self, filename):
103 def read(self, filename):
100 "read and parse notebook into NotebookNode called self.nb"
104 "read and parse notebook into NotebookNode called self.nb"
101 with open(filename) as f:
105 with open(filename) as f:
102 self.nb = nbformat.read(f, 'json')
106 self.nb = nbformat.read(f, 'json')
103
107
@@ -1,7 +1,9 b''
1 # coding: utf-8
1 # coding: utf-8
2 import sys
2 from converters.template import *
3 from converters.template import *
3 C = ConverterTemplate()
4 C = ConverterTemplate(tplfile=sys.argv[1])
4 C.read('tests/ipynbref/IntroNumPy.orig.ipynb')
5 C.read('tests/ipynbref/IntroNumPy.orig.ipynb')
6
5 S = C.convert()
7 S = C.convert()
6 with open('temp.txt','w') as f:
8 with open('temp.txt','w') as f:
7 f.write(S)
9 f.write(S)
@@ -1,37 +1,48 b''
1 {%- extends 'basic.tpl' -%}
1 {%- extends 'null.tpl' -%}
2
2
3 {% block in_prompt %}
4 # In[{{cell.prompt_number if cell.prompt_number else ' '}}]:
5 {% endblock in_prompt %}
6
7 {% block traceback_line %}
8 {{ line |indent| rm_ansi }}
9 {% endblock traceback_line %}
10
11
12 {% block pyout %}
13 {{ output.text| indent | pycomment}}
14 {% endblock pyout %}
15
16
17 {#
3 {% block codecell scoped %}
18 {% block codecell scoped %}
4 # In[{{cell.prompt_number if cell.prompt_number else ' '}}]:
19 # In[{{cell.prompt_number if cell.prompt_number else ' '}}]:
5 {{ cell.input }}
20 {{ cell.input }}
6 {% if cell.outputs %}
21 {% if cell.outputs %}
7 # Out[{{cell.prompt_number}}]:
22 # Out[{{cell.prompt_number}}]:
8 {%- for output in cell.outputs -%}
23 {%- for output in cell.outputs -%}
9 {%- if output.output_type in ['pyout','stream']%}
24 {%- if output.output_type in ['pyout','stream']%}
10 {{ output.text| indent | pycomment}}
25
11 {%- elif output.output_type in ['display_data'] %}
26 {%- elif output.output_type in ['display_data'] %}
12 {{"# image file: fucking display_data"}}
27 {{"# image file: fucking display_data"}}
13 {%- elif output.output_type in ['pyerr'] %}
14 {%- for line in output.traceback %}
15 {{ line |indent| rm_ansi}}
16 {%- endfor %}
17 {%- endif %}
18 {%- endfor -%}
28 {%- endfor -%}
19 {% endif %}
29 {% endif %}
20
30
21 {% endblock codecell %}
31 {% endblock codecell %}
32 #}
22
33
23 {% block markdowncell scoped %}
34 {% block markdowncell scoped %}
24 {{ cell.source | pycomment | rm_fake}}
35 {#{{ cell.source | pycomment | rm_fake}}#}
25 {% endblock markdowncell %}
36 {% endblock markdowncell %}
26
37
27 {% block headingcell scoped %}
38 {% block headingcell scoped %}
28 {{ '#' * cell.level }}{{ cell.source | pycomment}}
39 {#{{ '#' * cell.level }}{{ cell.source | pycomment}}#}
29 {% endblock headingcell %}
40 {% endblock headingcell %}
30
41
31 {% block rawcell scoped %}
42 {% block rawcell scoped %}
32 {{ cell.source | pycomment }}
43 {#{{ cell.source | pycomment }}#}
33 {% endblock rawcell %}
44 {% endblock rawcell %}
34
45
35 {% block unknowncell scoped %}
46 {% block unknowncell scoped %}
36 unknown type {{cell.type}}
47 {#unknown type {{cell.type}}#}
37 {% endblock unknowncell %}
48 {% endblock unknowncell %}
General Comments 0
You need to be logged in to leave comments. Login now