##// END OF EJS Templates
Cleaning of reveal converter to make the PR
damianavila -
Show More
@@ -1,12 +1,10 b''
1 1 from __future__ import absolute_import
2 2
3 3 from converters.html import ConverterHTML
4 from converters.utils import text_cell#, output_container
5 from converters.utils import highlight, coalesce_streams#, ansi2html
6
7 #from IPython.utils import path
8 #from IPython.utils.text import indent, dedent
4 from converters.utils import text_cell
5 from converters.utils import highlight, coalesce_streams
9 6 from markdown import markdown
7
10 8 import os
11 9 import io
12 10 import itertools
@@ -16,88 +14,11 b' class ConverterReveal(ConverterHTML):'
16 14 #"""
17 15 #Convert a notebook to a html slideshow.
18 16
19 #It generates a static html slideshow based in markdown and reveal.js.
20 #The delimiters for each slide, subslide, and fragment are retrieved
21 #from the 'slideshow' metadata.
17 #It generates a static html slideshow based reveal.js.
18 #The delimiters for each "Header slide", "Slide"", and "Fragment"
19 #are retrieved from the 'slideshow' metadata.
22 20 #"""
23 21
24 #def __init__(self):
25 #super(ConverterReveal, self).__init__()
26
27 #extension = 'html'
28 #blank_symbol = ' '
29
30 #def in_tag(self, tag, src, attrs=None):
31 #"""Return a list of elements bracketed by the given tag"""
32 #attr_s = '' if attrs is None else \
33 #' '.join("%s=%s" % (attr, value)
34 #for attr, value in attrs.iteritems())
35 #return ['<%s %s>' % (tag, attr_s), src, '</%s>' % tag]
36
37 #def _ansi_colored(self, text):
38 #return ['<pre>%s</pre>' % ansi2html(text)]
39
40 #def _stylesheet(self, fname):
41 #with io.open(fname, encoding='utf-8') as f:
42 #s = f.read()
43 #return self.in_tag('style', s, dict(type='"text/css"'))
44
45 #def _out_prompt(self, output):
46 #if output.output_type == 'pyout':
47 #content = 'Out[%s]:' % self._get_prompt_number(output)
48 #else:
49 #content = ''
50 #return ['<div class="prompt output_prompt">%s</div>' % content]
51
52 #def header_body(self):
53 #"""Return the body of the header as a list of strings."""
54
55 #from pygments.formatters import HtmlFormatter
56
57 #header = []
58 #static = os.path.join(path.get_ipython_package_dir(),
59 #'frontend', 'html', 'notebook', 'static',
60 #)
61 #here = os.path.split(os.path.realpath(__file__))[0]
62 #css = os.path.join(static, 'css')
63 #for sheet in [
64 ## do we need jquery and prettify?
65 ## os.path.join(static, 'jquery', 'css', 'themes', 'base',
66 ## 'jquery-ui.min.css'),
67 ## os.path.join(static, 'prettify', 'prettify.css'),
68 #os.path.join(css, 'boilerplate.css'),
69 #os.path.join(css, 'fbm.css'),
70 #os.path.join(css, 'notebook.css'),
71 #os.path.join(css, 'renderedhtml.css'),
72 ## our overrides:
73 #os.path.join(here, '..', 'css', 'static_html.css'),
74 #]:
75 #header.extend(self._stylesheet(sheet))
76
77 ## pygments css
78 #pygments_css = HtmlFormatter().get_style_defs('.highlight')
79 #header.extend(['<meta charset="UTF-8">'])
80 #header.extend(self.in_tag('style', pygments_css,
81 #dict(type='"text/css"')))
82
83 ## TODO: this should be allowed to use local mathjax:
84 #header.extend(self.in_tag('script', '', {'type': '"text/javascript"',
85 #'src': '"https://c328740.ssl.cf1.rackcdn.com/mathjax/'
86 #'latest/MathJax.js?config=TeX-AMS_HTML"',
87 #}))
88 #with io.open(os.path.join(here, '..', 'js', 'initmathjax.js'),
89 #encoding='utf-8') as f:
90 #header.extend(self.in_tag('script', f.read(),
91 #{'type': '"text/javascript"'}))
92 #return header
93
94 #def optional_header(self):
95 #return ['<html>', '<head>'] + self.header_body() + \
96 #['</head>', '<body>']
97
98 #def optional_footer(self):
99 #return ['</body>', '</html>']
100
101 22 @text_cell
102 23 def render_heading(self, cell):
103 24 marker = cell.level
@@ -146,63 +67,10 b' class ConverterReveal(ConverterHTML):'
146 67 def render_raw(self, cell):
147 68 if self.raw_as_verbatim:
148 69 return [self.in_tag('pre', self.meta2str(cell.metadata)),
149 self.in_tag('pre', cell.source)] # testing
70 self.in_tag('pre', cell.source)]
150 71 else:
151 72 return [self.meta2str(cell.metadata), cell.source]
152 73
153 #@output_container
154 #def render_pyout(self, output):
155 #for fmt in ['html', 'latex', 'png', 'jpeg', 'svg', 'text']:
156 #if fmt in output:
157 #conv_fn = self.dispatch_display_format(fmt)
158 #return conv_fn(output)
159 #return []
160
161 #render_display_data = render_pyout
162
163 #@output_container
164 #def render_stream(self, output):
165 #return self._ansi_colored(output.text)
166
167 #@output_container
168 #def render_pyerr(self, output):
169 ## Note: a traceback is a *list* of frames.
170 ## lines = []
171
172 ## stb =
173 #return self._ansi_colored('\n'.join(output.traceback))
174
175 #def _img_lines(self, img_file):
176 #return ['<img src="%s">' % img_file, '</img>']
177
178 #def _unknown_lines(self, data):
179 #return ['<h2>Warning:: Unknown cell</h2>'] + self.in_tag('pre', data)
180
181 #def render_display_format_png(self, output):
182 #return ['<img src="data:image/png;base64,%s"></img>' % output.png]
183
184 #def render_display_format_svg(self, output):
185 #return [output.svg]
186
187 #def render_display_format_jpeg(self, output):
188 #return ['<img src="data:image/jpeg;base64,%s"></img>' % output.jpeg]
189
190 #def render_display_format_text(self, output):
191 #return self._ansi_colored(output.text)
192
193 #def render_display_format_html(self, output):
194 #return [output.html]
195
196 #def render_display_format_latex(self, output):
197 #return [output.latex]
198
199 #def render_display_format_json(self, output):
200 ## html ignores json
201 #return []
202
203 #def render_display_format_javascript(self, output):
204 #return [output.javascript]
205
206 74 def meta2str(self, meta):
207 75 "transform metadata dict (containing slides delimiters) to string "
208 76 try:
General Comments 0
You need to be logged in to leave comments. Login now