Show More
@@ -15,6 +15,8 b' Exporter that exports Basic HTML.' | |||||
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 |
|
16 | |||
17 | from IPython.utils.traitlets import Unicode |
|
17 | from IPython.utils.traitlets import Unicode | |
|
18 | from IPython.config import Config | |||
|
19 | from copy import deepcopy | |||
18 |
|
20 | |||
19 | import nbconvert.transformers.csshtmlheader |
|
21 | import nbconvert.transformers.csshtmlheader | |
20 |
|
22 | |||
@@ -42,6 +44,20 b' class BasicHtmlExporter(exporter.Exporter):' | |||||
42 | 'basichtml', config=True, |
|
44 | 'basichtml', config=True, | |
43 | help="Name of the template file to use") |
|
45 | help="Name of the template file to use") | |
44 |
|
46 | |||
|
47 | _default_config = Config({}) | |||
|
48 | ||||
|
49 | def __init__(self, transformers=None, filters=None, config=None, **kw): | |||
|
50 | ||||
|
51 | c = self.default_config | |||
|
52 | if config : | |||
|
53 | c.update(config) | |||
|
54 | ||||
|
55 | super(BasicHtmlExporter, self).__init__(transformers=transformers, | |||
|
56 | filters=filters, | |||
|
57 | config=c, | |||
|
58 | **kw) | |||
|
59 | ||||
|
60 | ||||
45 | def _register_transformers(self): |
|
61 | def _register_transformers(self): | |
46 | """ |
|
62 | """ | |
47 | Register all of the transformers needed for this exporter. |
|
63 | Register all of the transformers needed for this exporter. | |
@@ -52,4 +68,4 b' class BasicHtmlExporter(exporter.Exporter):' | |||||
52 |
|
68 | |||
53 | #Register CSSHtmlHeaderTransformer transformer |
|
69 | #Register CSSHtmlHeaderTransformer transformer | |
54 | self.register_transformer(nbconvert.transformers.csshtmlheader.CSSHtmlHeaderTransformer) |
|
70 | self.register_transformer(nbconvert.transformers.csshtmlheader.CSSHtmlHeaderTransformer) | |
55 | No newline at end of file |
|
71 |
@@ -20,9 +20,11 b' from __future__ import print_function, absolute_import' | |||||
20 | import io |
|
20 | import io | |
21 | import os |
|
21 | import os | |
22 | import inspect |
|
22 | import inspect | |
|
23 | from copy import deepcopy | |||
23 |
|
24 | |||
24 | # IPython imports |
|
25 | # IPython imports | |
25 | from IPython.config.configurable import Configurable |
|
26 | from IPython.config.configurable import Configurable | |
|
27 | from IPython.config import Config | |||
26 | from IPython.nbformat import current as nbformat |
|
28 | from IPython.nbformat import current as nbformat | |
27 | from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Bool |
|
29 | from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Bool | |
28 | from IPython.utils.text import indent |
|
30 | from IPython.utils.text import indent | |
@@ -166,6 +168,13 b' class Exporter(Configurable):' | |||||
166 | self.environment.filters[key] = user_filter(config=config) |
|
168 | self.environment.filters[key] = user_filter(config=config) | |
167 | else: |
|
169 | else: | |
168 | self.environment.filters[key] = user_filter |
|
170 | self.environment.filters[key] = user_filter | |
|
171 | ||||
|
172 | @property | |||
|
173 | def default_config(self): | |||
|
174 | if self._default_config: | |||
|
175 | return deepcopy(self._default_config) | |||
|
176 | else : | |||
|
177 | return Config({}) | |||
169 |
|
178 | |||
170 |
|
179 | |||
171 | def from_notebook_node(self, nb, resources=None): |
|
180 | def from_notebook_node(self, nb, resources=None): |
@@ -14,6 +14,7 b' Exporter for exporting notebooks to restructured text.' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | from IPython.utils.traitlets import Unicode |
|
16 | from IPython.utils.traitlets import Unicode | |
|
17 | from IPython.config import Config | |||
17 |
|
18 | |||
18 | # local import |
|
19 | # local import | |
19 | import exporter |
|
20 | import exporter | |
@@ -34,4 +35,18 b' class RstExporter(exporter.Exporter):' | |||||
34 | template_file = Unicode( |
|
35 | template_file = Unicode( | |
35 | 'rst', config=True, |
|
36 | 'rst', config=True, | |
36 | help="Name of the template file to use") |
|
37 | help="Name of the template file to use") | |
37 | No newline at end of file |
|
38 | ||
|
39 | _default_config = Config({'ExtractFigureTransformer':{'enabled':True}}) | |||
|
40 | ||||
|
41 | ||||
|
42 | def __init__(self, transformers=None, filters=None, config=None, **kw): | |||
|
43 | ||||
|
44 | c = self.default_config | |||
|
45 | if config : | |||
|
46 | c.update(config) | |||
|
47 | ||||
|
48 | super(RstExporter, self).__init__(transformers=transformers, | |||
|
49 | filters=filters, | |||
|
50 | config=c, | |||
|
51 | **kw) | |||
|
52 |
@@ -24,11 +24,11 b' class ActivatableTransformer(ConfigurableTransformer):' | |||||
24 | """ConfigurableTransformer that has an enabled flag |
|
24 | """ConfigurableTransformer that has an enabled flag | |
25 |
|
25 | |||
26 | Inherit from this if you just want to have a transformer which is |
|
26 | Inherit from this if you just want to have a transformer which is | |
27 |
|
|
27 | disable by default and can be enabled via the config by | |
28 | 'c.YourTransformerName.enabled = True' |
|
28 | 'c.YourTransformerName.enabled = True' | |
29 | """ |
|
29 | """ | |
30 |
|
30 | |||
31 |
enabled = Bool( |
|
31 | enabled = Bool(False, config=True) | |
32 |
|
32 | |||
33 | def __call__(self, nb, resources): |
|
33 | def __call__(self, nb, resources): | |
34 | """ |
|
34 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now