Show More
@@ -1,54 +1,61 | |||
|
1 | 1 | """ |
|
2 | 2 | Reveal slide show exporter. |
|
3 | 3 | """ |
|
4 | 4 | #----------------------------------------------------------------------------- |
|
5 | 5 | # Copyright (c) 2013, the IPython Development Team. |
|
6 | 6 | # |
|
7 | 7 | # Distributed under the terms of the Modified BSD License. |
|
8 | 8 | # |
|
9 | 9 | # The full license is in the file COPYING.txt, distributed with this software. |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | # Imports |
|
14 | 14 | #----------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | from IPython.utils.traitlets import Unicode |
|
17 | 17 | from IPython.config import Config |
|
18 | 18 | |
|
19 | 19 | from .basichtml import BasicHTMLExporter |
|
20 | 20 | from IPython.nbconvert import transformers |
|
21 | 21 | |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | # Classes |
|
24 | 24 | #----------------------------------------------------------------------------- |
|
25 | 25 | |
|
26 | 26 | class RevealExporter(BasicHTMLExporter): |
|
27 | 27 | """ |
|
28 | 28 | Exports a Reveal slide show (.HTML) which may be rendered in a web browser. |
|
29 | 29 | """ |
|
30 | 30 | |
|
31 | 31 | file_extension = Unicode( |
|
32 | 32 | 'reveal.html', config=True, |
|
33 | 33 | help="Extension of the file that should be written to disk") |
|
34 | 34 | |
|
35 | 35 | template_file = Unicode( |
|
36 | 36 | 'reveal', config=True, |
|
37 | 37 | help="Name of the template file to use") |
|
38 | 38 | |
|
39 | 39 | def _register_transformers(self): |
|
40 | 40 | """ |
|
41 | 41 | Register all of the transformers needed for this exporter. |
|
42 | 42 | """ |
|
43 | 43 | |
|
44 | 44 | #Register the transformers of the base class. |
|
45 | 45 | super(RevealExporter, self)._register_transformers() |
|
46 | 46 | |
|
47 | 47 | #Register reveal help transformer |
|
48 | 48 | self.register_transformer(transformers.RevealHelpTransformer) |
|
49 | 49 | |
|
50 | 50 | @property |
|
51 | 51 | def default_config(self): |
|
52 | c = Config({'CSSHTMLHeaderTransformer':{'enabled':True}}) | |
|
52 | c = Config({ | |
|
53 | 'CSSHTMLHeaderTransformer':{ | |
|
54 | 'enabled':True | |
|
55 | }, | |
|
56 | 'RevealHelpTransformer':{ | |
|
57 | 'enabled':True, | |
|
58 | }, | |
|
59 | }) | |
|
53 | 60 | c.merge(super(RevealExporter,self).default_config) |
|
54 | 61 | return c |
@@ -1,180 +1,181 | |||
|
1 | 1 | {%- extends 'slides.tpl' -%} |
|
2 | 2 | |
|
3 | 3 | |
|
4 | 4 | {% block header %} |
|
5 | 5 | <!DOCTYPE html> |
|
6 | 6 | <html> |
|
7 | 7 | <head> |
|
8 | 8 | |
|
9 | 9 | <meta charset="utf-8" /> |
|
10 | 10 | <meta http-equiv="X-UA-Compatible" content="chrome=1"> |
|
11 | 11 | |
|
12 | 12 | <meta name="apple-mobile-web-app-capable" content="yes" /> |
|
13 | 13 | <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
|
14 | 14 | |
|
15 | <link rel="stylesheet" href="reveal.js/css/reveal.css"> | |
|
16 |
<link rel="stylesheet" href="reveal. |
|
|
15 | <!-- General and theme style sheets --> | |
|
16 | <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/reveal.css"> | |
|
17 | <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/theme/simple.css" id="theme"> | |
|
17 | 18 | |
|
18 | 19 | <!-- For syntax highlighting --> |
|
19 |
<link rel="stylesheet" href="reveal. |
|
|
20 | <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/lib/css/zenburn.css"> | |
|
20 | 21 | |
|
21 | 22 | <!-- If the query includes 'print-pdf', use the PDF print sheet --> |
|
22 | 23 | <script> |
|
23 |
document.write( '<link rel="stylesheet" href="reveal. |
|
|
24 | document.write( '<link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/print' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' ); | |
|
24 | 25 | </script> |
|
25 | 26 | |
|
26 | 27 | <!--[if lt IE 9]> |
|
27 |
<script src="reveal. |
|
|
28 | <script src="{{resources.reveal.url_prefix}}/lib/js/html5shiv.js"></script> | |
|
28 | 29 | <![endif]--> |
|
29 | 30 | |
|
30 | 31 | {% for css in resources.inlining.css -%} |
|
31 | 32 | <style type="text/css"> |
|
32 | 33 | {{css}} |
|
33 | 34 | </style> |
|
34 | 35 | {% endfor %} |
|
35 | 36 | |
|
36 | 37 | <style type="text/css"> |
|
37 | 38 | /* Overrides of notebook CSS for static HTML export */ |
|
38 | 39 | .reveal { |
|
39 | 40 | font-size: 20px; |
|
40 | 41 | overflow-y: auto; |
|
41 | 42 | overflow-x: hidden; |
|
42 | 43 | } |
|
43 | 44 | .reveal pre { |
|
44 | 45 | width: 95%; |
|
45 | 46 | padding: 0.4em; |
|
46 | 47 | margin: 0px; |
|
47 | 48 | font-family: monospace, sans-serif; |
|
48 | 49 | font-size: 80%; |
|
49 | 50 | box-shadow: 0px 0px 0px rgba(0, 0, 0, 0); |
|
50 | 51 | } |
|
51 | 52 | .reveal section img { |
|
52 | 53 | border: 0px solid black; |
|
53 | 54 | box-shadow: 0 0 10px rgba(0, 0, 0, 0); |
|
54 | 55 | } |
|
55 | 56 | .reveal .slides { |
|
56 | 57 | text-align: left; |
|
57 | 58 | } |
|
58 | 59 | .reveal.fade { |
|
59 | 60 | opacity: 1; |
|
60 | 61 | } |
|
61 | 62 | div.input_area { |
|
62 | 63 | padding: 0.06em; |
|
63 | 64 | } |
|
64 | 65 | div.code_cell { |
|
65 | 66 | background-color: transparent; |
|
66 | 67 | } |
|
67 | 68 | div.prompt { |
|
68 | 69 | width: 11ex; |
|
69 | 70 | padding: 0.4em; |
|
70 | 71 | margin: 0px; |
|
71 | 72 | font-family: monospace, sans-serif; |
|
72 | 73 | font-size: 80%; |
|
73 | 74 | text-align: right; |
|
74 | 75 | } |
|
75 | 76 | div.output_area pre { |
|
76 | 77 | font-family: monospace, sans-serif; |
|
77 | 78 | font-size: 80%; |
|
78 | 79 | } |
|
79 | 80 | div.output_prompt { |
|
80 | 81 | /* 5px right shift to account for margin in parent container */ |
|
81 | 82 | margin: 5px 5px 0 -5px; |
|
82 | 83 | } |
|
83 | 84 | .rendered_html p { |
|
84 | 85 | text-align: inherit; |
|
85 | 86 | } |
|
86 | 87 | </style> |
|
87 | 88 | </head> |
|
88 | 89 | {% endblock header%} |
|
89 | 90 | |
|
90 | 91 | |
|
91 | 92 | {% block body %} |
|
92 | 93 | <body> |
|
93 | 94 | <div class="reveal"><div class="slides"> |
|
94 | 95 | |
|
95 | 96 | {{ super() }} |
|
96 | 97 | |
|
97 | 98 | </div></div> |
|
98 | 99 | |
|
99 |
<!-- |
|
|
100 | <!-- | |
|
100 | 101 | Uncomment the following block and the addthis_widget.js (see below inside dependencies) |
|
101 | 102 | to get enable social buttons. |
|
102 | 103 | --> |
|
103 | 104 | |
|
104 | 105 | <!-- |
|
105 | 106 | <div class="addthis_toolbox addthis_floating_style addthis_32x32_style" style="left:20px;top:20px;"> |
|
106 | 107 | <a class="addthis_button_twitter"></a> |
|
107 | 108 | <a class="addthis_button_google_plusone_share"></a> |
|
108 | 109 | <a class="addthis_button_linkedin"></a> |
|
109 | 110 | <a class="addthis_button_facebook"></a> |
|
110 | 111 | <a class="addthis_button_more"></a> |
|
111 | 112 | </div> |
|
112 | 113 | --> |
|
113 | 114 | |
|
114 |
<script src="reveal. |
|
|
115 | <script src="{{resources.reveal.url_prefix}}/lib/js/head.min.js"></script> | |
|
115 | 116 | |
|
116 |
<script src="reveal. |
|
|
117 | <script src="{{resources.reveal.url_prefix}}/js/reveal.js"></script> | |
|
117 | 118 | |
|
118 | 119 | <script> |
|
119 | 120 | |
|
120 | 121 | // Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration |
|
121 | 122 | Reveal.initialize({ |
|
122 | 123 | controls: true, |
|
123 | 124 | progress: true, |
|
124 | 125 | history: true, |
|
125 | 126 | |
|
126 | 127 | theme: Reveal.getQueryHash().theme, // available themes are in /css/theme |
|
127 | 128 | transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none |
|
128 | 129 | |
|
129 | 130 | // Optional libraries used to extend on reveal.js |
|
130 | 131 | dependencies: [ |
|
131 |
{ src: |
|
|
132 |
{ src: |
|
|
133 |
{ src: |
|
|
132 | { src: "{{resources.reveal.url_prefix}}/lib/js/classList.js", condition: function() { return !document.body.classList; } }, | |
|
133 | { src: "{{resources.reveal.url_prefix}}/plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, | |
|
134 | { src: "{{resources.reveal.url_prefix}}/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } } | |
|
134 | 135 | // { src: 'http://s7.addthis.com/js/300/addthis_widget.js', async: true}, |
|
135 | 136 | ] |
|
136 | 137 | }); |
|
137 | 138 | </script> |
|
138 | 139 | |
|
139 | 140 | <!-- MathJax configuration --> |
|
140 | 141 | <script type="text/x-mathjax-config"> |
|
141 | 142 | MathJax.Hub.Config({ |
|
142 | 143 | tex2jax: { |
|
143 | 144 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
144 | 145 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ] |
|
145 | 146 | }, |
|
146 | 147 | displayAlign: 'left', // Change this to 'center' to center equations. |
|
147 | 148 | "HTML-CSS": { |
|
148 | 149 | styles: {'.MathJax_Display': {"margin": 0}} |
|
149 | 150 | } |
|
150 | 151 | }); |
|
151 | 152 | </script> |
|
152 | 153 | <!-- End of mathjax configuration --> |
|
153 | 154 | |
|
154 | 155 | <script> |
|
155 |
// We wait for the onload function to load MathJax after the page is completely loaded. |
|
|
156 | // We wait for the onload function to load MathJax after the page is completely loaded. | |
|
156 | 157 | // MathJax is loaded 1 unit of time after the page is ready. |
|
157 | 158 | // This hack prevent problems when you load multiple js files (i.e. social button from addthis). |
|
158 | 159 | // |
|
159 | 160 | window.onload = function () { |
|
160 | 161 | setTimeout(function () { |
|
161 | 162 | var script = document.createElement("script"); |
|
162 | 163 | script.type = "text/javascript"; |
|
163 | 164 | script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"; |
|
164 | 165 | document.getElementsByTagName("head")[0].appendChild(script); |
|
165 | 166 | },1) |
|
166 | 167 | } |
|
167 | 168 | </script> |
|
168 | 169 | |
|
169 | 170 | <script> |
|
170 | 171 | Reveal.addEventListener( 'slidechanged', function( event ) { |
|
171 | 172 | MathJax.Hub.Rerender(event.currentSlide); |
|
172 | 173 | }); |
|
173 | 174 | </script> |
|
174 | 175 | |
|
175 | 176 | </body> |
|
176 | 177 | {% endblock body %} |
|
177 | 178 | |
|
178 | 179 | {% block footer %} |
|
179 | 180 | </html> |
|
180 | 181 | {% endblock footer %} |
@@ -1,52 +1,62 | |||
|
1 | 1 | """Module that pre-processes the notebook for export via Reveal. |
|
2 | 2 | """ |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (c) 2013, the IPython Development Team. |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the Modified BSD License. |
|
7 | 7 | # |
|
8 | 8 | # The full license is in the file COPYING.txt, distributed with this software. |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | # Imports |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | from .base import ConfigurableTransformer |
|
16 | from IPython.utils.traitlets import Unicode | |
|
16 | 17 | |
|
17 | 18 | #----------------------------------------------------------------------------- |
|
18 | 19 | # Classes and functions |
|
19 | 20 | #----------------------------------------------------------------------------- |
|
20 | 21 | |
|
21 | 22 | class RevealHelpTransformer(ConfigurableTransformer): |
|
22 | 23 | |
|
24 | url_prefix = Unicode('//cdn.jsdelivr.net/reveal.js/2.4.0', | |
|
25 | config=True, | |
|
26 | help="""If you want to use a local reveal.js library, | |
|
27 | use 'url_prefix':'reveal.js' in your config object.""") | |
|
28 | ||
|
23 | 29 | def call(self, nb, resources): |
|
24 | 30 | """ |
|
25 | 31 | Called once to 'transform' contents of the notebook. |
|
26 | ||
|
32 | ||
|
27 | 33 | Parameters |
|
28 | 34 | ---------- |
|
29 | 35 | nb : NotebookNode |
|
30 | 36 | Notebook being converted |
|
31 | 37 | resources : dictionary |
|
32 | 38 | Additional resources used in the conversion process. Allows |
|
33 | 39 | transformers to pass variables into the Jinja engine. |
|
34 | 40 | """ |
|
35 | ||
|
36 | ||
|
41 | ||
|
42 | ||
|
37 | 43 | for worksheet in nb.worksheets : |
|
38 | 44 | for i, cell in enumerate(worksheet.cells): |
|
39 | 45 | |
|
40 | 46 | #Make sure the cell has slideshow metadata. |
|
41 | 47 | cell.metadata.align_type = cell.get('metadata', {}).get('slideshow', {}).get('align_type', 'Left') |
|
42 | 48 | cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-') |
|
43 | 49 | |
|
44 | 50 | #Get the slide type. If type is start of subslide or slide, |
|
45 | 51 | #end the last subslide/slide. |
|
46 | 52 | if cell.metadata.slide_type in ['slide']: |
|
47 | 53 | worksheet.cells[i - 1].metadata.slide_helper = 'slide_end' |
|
48 | 54 | if cell.metadata.slide_type in ['subslide']: |
|
49 | 55 | worksheet.cells[i - 1].metadata.slide_helper = 'subslide_end' |
|
50 | ||
|
56 | ||
|
57 | ||
|
58 | if 'reveal' not in resources: | |
|
59 | resources['reveal'] = {} | |
|
60 | resources['reveal']['url_prefix'] = self.url_prefix | |
|
61 | ||
|
51 | 62 | return nb, resources |
|
52 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now