Show More
@@ -14,11 +14,8 b' import itertools' | |||||
14 |
|
14 | |||
15 | class ConverterReveal(ConverterHTML): |
|
15 | class ConverterReveal(ConverterHTML): | |
16 | #""" |
|
16 | #""" | |
17 |
#Convert a notebook to a html slideshow |
|
17 | #Convert a ipython notebook to a html slideshow | |
18 |
|
18 | #based in reveal.js library. | ||
19 | #It generates a static html slideshow based reveal.js. |
|
|||
20 | #The delimiters for each "Header slide", "Slide"", and "Fragment" |
|
|||
21 | #are retrieved from the 'slideshow' metadata. |
|
|||
22 | #""" |
|
19 | #""" | |
23 |
|
20 | |||
24 | @text_cell |
|
21 | @text_cell | |
@@ -30,13 +27,10 b' class ConverterReveal(ConverterHTML):' | |||||
30 | def render_code(self, cell): |
|
27 | def render_code(self, cell): | |
31 | if not cell.input: |
|
28 | if not cell.input: | |
32 | return [] |
|
29 | return [] | |
33 |
|
||||
34 | lines = [] |
|
30 | lines = [] | |
35 | meta_code = self.meta2str(cell.metadata) |
|
31 | meta_code = self.meta2str(cell.metadata) | |
36 | lines.extend([meta_code]) |
|
32 | lines.extend([meta_code]) | |
37 |
|
||||
38 | lines.extend(['<div class="cell border-box-sizing code_cell vbox">']) |
|
33 | lines.extend(['<div class="cell border-box-sizing code_cell vbox">']) | |
39 |
|
||||
40 | lines.append('<div class="input hbox">') |
|
34 | lines.append('<div class="input hbox">') | |
41 | n = self._get_prompt_number(cell) |
|
35 | n = self._get_prompt_number(cell) | |
42 | lines.append( |
|
36 | lines.append( | |
@@ -46,20 +40,15 b' class ConverterReveal(ConverterHTML):' | |||||
46 | lines.append(highlight(cell.input)) |
|
40 | lines.append(highlight(cell.input)) | |
47 | lines.append('</div>') # input_area |
|
41 | lines.append('</div>') # input_area | |
48 | lines.append('</div>') # input |
|
42 | lines.append('</div>') # input | |
49 |
|
||||
50 | if cell.outputs: |
|
43 | if cell.outputs: | |
51 | lines.append('<div class="vbox output_wrapper">') |
|
44 | lines.append('<div class="vbox output_wrapper">') | |
52 | lines.append('<div class="output vbox">') |
|
45 | lines.append('<div class="output vbox">') | |
53 |
|
||||
54 | for output in coalesce_streams(cell.outputs): |
|
46 | for output in coalesce_streams(cell.outputs): | |
55 | conv_fn = self.dispatch(output.output_type) |
|
47 | conv_fn = self.dispatch(output.output_type) | |
56 | lines.extend(conv_fn(output)) |
|
48 | lines.extend(conv_fn(output)) | |
57 |
|
||||
58 | lines.append('</div>') # output |
|
49 | lines.append('</div>') # output | |
59 | lines.append('</div>') # output_wrapper |
|
50 | lines.append('</div>') # output_wrapper | |
60 |
|
||||
61 | lines.append('</div>') # cell |
|
51 | lines.append('</div>') # cell | |
62 |
|
||||
63 | return lines |
|
52 | return lines | |
64 |
|
53 | |||
65 | @text_cell |
|
54 | @text_cell | |
@@ -184,14 +173,11 b' class ConverterReveal(ConverterHTML):' | |||||
184 | return os.path.abspath(outfile) |
|
173 | return os.path.abspath(outfile) | |
185 |
|
174 | |||
186 | def header_body(self): |
|
175 | def header_body(self): | |
187 |
" |
|
176 | "return the body of the header as a list of strings" | |
188 |
|
||||
189 | from pygments.formatters import HtmlFormatter |
|
177 | from pygments.formatters import HtmlFormatter | |
190 |
|
||||
191 | header = [] |
|
178 | header = [] | |
192 | static = os.path.join(path.get_ipython_package_dir(), |
|
179 | static = os.path.join(path.get_ipython_package_dir(), | |
193 | 'frontend', 'html', 'notebook', 'static', |
|
180 | 'frontend', 'html', 'notebook', 'static',) | |
194 | ) |
|
|||
195 | here = os.path.split(os.path.realpath(__file__))[0] |
|
181 | here = os.path.split(os.path.realpath(__file__))[0] | |
196 | css = os.path.join(static, 'css') |
|
182 | css = os.path.join(static, 'css') | |
197 | for sheet in [ |
|
183 | for sheet in [ | |
@@ -207,13 +193,11 b' class ConverterReveal(ConverterHTML):' | |||||
207 | os.path.join(here, '..', 'css', 'reveal_html.css'), |
|
193 | os.path.join(here, '..', 'css', 'reveal_html.css'), | |
208 | ]: |
|
194 | ]: | |
209 | header.extend(self._stylesheet(sheet)) |
|
195 | header.extend(self._stylesheet(sheet)) | |
210 |
|
||||
211 | # pygments css |
|
196 | # pygments css | |
212 | pygments_css = HtmlFormatter().get_style_defs('.highlight') |
|
197 | pygments_css = HtmlFormatter().get_style_defs('.highlight') | |
213 | header.extend(['<meta charset="UTF-8">']) |
|
198 | header.extend(['<meta charset="UTF-8">']) | |
214 | header.extend(self.in_tag('style', pygments_css, |
|
199 | header.extend(self.in_tag('style', pygments_css, | |
215 | dict(type='"text/css"'))) |
|
200 | dict(type='"text/css"'))) | |
216 |
|
||||
217 | return header |
|
201 | return header | |
218 |
|
202 | |||
219 | def template_read(self): |
|
203 | def template_read(self): | |
@@ -235,7 +219,6 b' class ConverterReveal(ConverterHTML):' | |||||
235 |
|
219 | |||
236 | def optional_header(self): |
|
220 | def optional_header(self): | |
237 | optional_header_body = self.template_split() |
|
221 | optional_header_body = self.template_split() | |
238 | #return optional_header_body[0] |
|
|||
239 | return ['<!DOCTYPE html>', '<html>', '<head>'] + \ |
|
222 | return ['<!DOCTYPE html>', '<html>', '<head>'] + \ | |
240 | optional_header_body[0] + self.header_body() + \ |
|
223 | optional_header_body[0] + self.header_body() + \ | |
241 | ['</head>', '<body>'] |
|
224 | ['</head>', '<body>'] |
@@ -55,14 +55,14 b'' | |||||
55 | }); |
|
55 | }); | |
56 | </script> |
|
56 | </script> | |
57 |
|
57 | |||
58 | <script> |
|
58 | //<script> | |
59 | Reveal.addEventListener("mousedown", handleClick, false); |
|
59 | //Reveal.addEventListener("mousedown", handleClick, false); | |
60 | Reveal.addEventListener("contextmenu", function(e) { e.preventDefault(); }, false); |
|
60 | //Reveal.addEventListener("contextmenu", function(e) { e.preventDefault(); }, false); | |
61 |
|
61 | |||
62 | function handleClick(e) { |
|
62 | //function handleClick(e) { | |
63 | e.preventDefault(); |
|
63 | //e.preventDefault(); | |
64 | if(e.button === 2) Reveal.next(); |
|
64 | //if(e.button === 2) Reveal.next(); | |
65 | if(e.button === 1) Reveal.toggleOverview(); |
|
65 | //if(e.button === 1) Reveal.toggleOverview(); | |
66 | if(e.button === 0) Reveal.prev(); |
|
66 | //if(e.button === 0) Reveal.prev(); | |
67 | } |
|
67 | //} | |
68 | </script> |
|
68 | //</script> |
General Comments 0
You need to be logged in to leave comments.
Login now