Show More
@@ -18,7 +18,7 b' from .utils import highlight, ansi2html' | |||||
18 | from .utils import markdown2latex |
|
18 | from .utils import markdown2latex | |
19 |
|
19 | |||
20 | from IPython.config.configurable import Configurable |
|
20 | from IPython.config.configurable import Configurable | |
21 |
from IPython.utils.traitlets import |
|
21 | from IPython.utils.traitlets import List | |
22 |
|
22 | |||
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
24 | # Class declarations |
|
24 | # Class declarations |
@@ -50,7 +50,7 b' texenv = Environment(' | |||||
50 | # IPython imports |
|
50 | # IPython imports | |
51 | from IPython.nbformat import current as nbformat |
|
51 | from IPython.nbformat import current as nbformat | |
52 | from IPython.config.configurable import Configurable |
|
52 | from IPython.config.configurable import Configurable | |
53 |
from IPython.utils.traitlets import ( Unicode, |
|
53 | from IPython.utils.traitlets import ( Unicode, List, Bool) | |
54 |
|
54 | |||
55 | #----------------------------------------------------------------------------- |
|
55 | #----------------------------------------------------------------------------- | |
56 | # Class declarations |
|
56 | # Class declarations |
@@ -20,7 +20,7 b' class ConfigurableTransformers(Configurable):' | |||||
20 | for index, cell in enumerate(worksheet.cells): |
|
20 | for index, cell in enumerate(worksheet.cells): | |
21 | worksheet.cells[index], other = self.cell_transform(cell, other, index) |
|
21 | worksheet.cells[index], other = self.cell_transform(cell, other, index) | |
22 | return nb, other |
|
22 | return nb, other | |
23 |
except NotImplementedError |
|
23 | except NotImplementedError: | |
24 | raise NotImplementedError('should be implemented by subclass') |
|
24 | raise NotImplementedError('should be implemented by subclass') | |
25 |
|
25 | |||
26 | def cell_transform(self, cell, other, index): |
|
26 | def cell_transform(self, cell, other, index): | |
@@ -36,9 +36,9 b' class ActivatableTransformer(ConfigurableTransformers):' | |||||
36 |
|
36 | |||
37 | def __call__(self, nb, other): |
|
37 | def __call__(self, nb, other): | |
38 | if not self.enabled : |
|
38 | if not self.enabled : | |
39 | return nb,other |
|
39 | return nb, other | |
40 | else : |
|
40 | else : | |
41 | return super(ActivatableTransformer,self).__call__(nb, other) |
|
41 | return super(ActivatableTransformer, self).__call__(nb, other) | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | def cell_preprocessor(function): |
|
44 | def cell_preprocessor(function): | |
@@ -119,13 +119,13 b' class ExtractFigureTransformer(ActivatableTransformer):' | |||||
119 |
|
119 | |||
120 |
|
120 | |||
121 | def cell_transform(self, cell, other, count): |
|
121 | def cell_transform(self, cell, other, count): | |
122 | if other.get('figures',None) is None : |
|
122 | if other.get('figures', None) is None : | |
123 | other['figures']={} |
|
123 | other['figures'] = {} | |
124 |
for |
|
124 | for out in cell.get('outputs', []): | |
125 | for type in self.display_data_priority: |
|
125 | for out_type in self.display_data_priority: | |
126 | if out.hasattr(type): |
|
126 | if out.hasattr(out_type): | |
127 | figname, key, data = self._new_figure(out[type], type, count) |
|
127 | figname, key, data = self._new_figure(out[out_type], out_type, count) | |
128 | out['key_'+type] = figname |
|
128 | out['key_'+out_type] = figname | |
129 | other['figures'][key] = data |
|
129 | other['figures'][key] = data | |
130 | count = count+1 |
|
130 | count = count+1 | |
131 | return cell, other |
|
131 | return cell, other | |
@@ -200,8 +200,8 b' class RevealHelpTransformer(ConfigurableTransformers):' | |||||
200 | else : |
|
200 | else : | |
201 | return False |
|
201 | return False | |
202 |
|
202 | |||
203 | def cell_transform(self, cell, other,count): |
|
203 | def cell_transform(self, cell, other, count): | |
204 | ctype = cell.metadata.get('slideshow',{}).get('slide_type',None) |
|
204 | ctype = cell.metadata.get('slideshow', {}).get('slide_type', None) | |
205 | if ctype in [None, '-'] : |
|
205 | if ctype in [None, '-'] : | |
206 | cell.metadata.slideshow = {} |
|
206 | cell.metadata.slideshow = {} | |
207 | cell.metadata.slideshow['slide_type'] = None |
|
207 | cell.metadata.slideshow['slide_type'] = None | |
@@ -230,7 +230,7 b' class RevealHelpTransformer(ConfigurableTransformers):' | |||||
230 | cell.metadata.slideshow.open_section = self.open_section() |
|
230 | cell.metadata.slideshow.open_section = self.open_section() | |
231 | cell.metadata.slideshow.open_subsection = self.open_subsection() |
|
231 | cell.metadata.slideshow.open_subsection = self.open_subsection() | |
232 | cell.metadata.slideshow.open_fragment = False |
|
232 | cell.metadata.slideshow.open_fragment = False | |
233 | return cell,other |
|
233 | return cell, other | |
234 |
|
234 | |||
235 |
|
235 | |||
236 | class CSSHtmlHeaderTransformer(ActivatableTransformer): |
|
236 | class CSSHtmlHeaderTransformer(ActivatableTransformer): | |
@@ -243,14 +243,14 b' class CSSHtmlHeaderTransformer(ActivatableTransformer):' | |||||
243 |
|
243 | |||
244 | Add this css in resources in the "inlining.css" key |
|
244 | Add this css in resources in the "inlining.css" key | |
245 | """ |
|
245 | """ | |
246 | resources['inlining']= {} |
|
246 | resources['inlining'] = {} | |
247 | resources['inlining']['css'] = self.header |
|
247 | resources['inlining']['css'] = self.header | |
248 | return nb, resources |
|
248 | return nb, resources | |
249 |
|
249 | |||
250 | header= [] |
|
250 | header = [] | |
251 |
|
251 | |||
252 | def __init__(self, config=None, **kw): |
|
252 | def __init__(self, config=None, **kw): | |
253 | super(CSSHtmlHeaderTransformer,self).__init__(config=config, **kw) |
|
253 | super(CSSHtmlHeaderTransformer, self).__init__(config=config, **kw) | |
254 | if self.enabled : |
|
254 | if self.enabled : | |
255 | self.regen_header() |
|
255 | self.regen_header() | |
256 |
|
256 |
General Comments 0
You need to be logged in to leave comments.
Login now