Show More
@@ -1,5 +1,5 b'' | |||||
1 | """This module defines Exporter, a highly configurable converter |
|
1 | """This module defines a base Exporter class. For Jinja template-based export, | |
2 | that uses Jinja2 to export notebook files into different formats. |
|
2 | see templateexporter.py. | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- |
@@ -1,6 +1,4 b'' | |||||
1 | """ |
|
1 | """HTML Exporter class""" | |
2 | Exporter that exports Basic HTML. |
|
|||
3 | """ |
|
|||
4 |
|
2 | |||
5 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
6 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
@@ -40,7 +38,10 b' class HTMLExporter(TemplateExporter):' | |||||
40 |
|
38 | |||
41 | default_template = Unicode('full', config=True, help="""Flavor of the data |
|
39 | default_template = Unicode('full', config=True, help="""Flavor of the data | |
42 | format to use. I.E. 'full' or 'basic'""") |
|
40 | format to use. I.E. 'full' or 'basic'""") | |
43 |
|
41 | |||
|
42 | def _raw_format_default(self): | |||
|
43 | return 'html' | |||
|
44 | ||||
44 | @property |
|
45 | @property | |
45 | def default_config(self): |
|
46 | def default_config(self): | |
46 | c = Config({ |
|
47 | c = Config({ |
@@ -1,9 +1,5 b'' | |||||
1 | """ |
|
1 | """LaTeX Exporter class""" | |
2 | Exporter that allows Latex Jinja templates to work. Contains logic to |
|
2 | ||
3 | appropriately prepare IPYNB files for export to LaTeX. Including but |
|
|||
4 | not limited to escaping LaTeX, fixing math region tags, using special |
|
|||
5 | tags to circumvent Jinja/Latex syntax conflicts. |
|
|||
6 | """ |
|
|||
7 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
8 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
9 | # |
|
5 | # | |
@@ -67,6 +63,9 b' class LatexExporter(TemplateExporter):' | |||||
67 | #Extension that the template files use. |
|
63 | #Extension that the template files use. | |
68 | template_extension = Unicode(".tplx", config=True) |
|
64 | template_extension = Unicode(".tplx", config=True) | |
69 |
|
65 | |||
|
66 | def _raw_format_default(self): | |||
|
67 | return 'latex' | |||
|
68 | ||||
70 |
|
69 | |||
71 | @property |
|
70 | @property | |
72 | def default_config(self): |
|
71 | def default_config(self): |
@@ -1,6 +1,5 b'' | |||||
1 | """ |
|
1 | """Markdown Exporter class""" | |
2 | Exporter that will export your ipynb to Markdown. |
|
2 | ||
3 | """ |
|
|||
4 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
5 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
6 | # |
|
5 | # | |
@@ -31,6 +30,12 b' class MarkdownExporter(TemplateExporter):' | |||||
31 | 'md', config=True, |
|
30 | 'md', config=True, | |
32 | help="Extension of the file that should be written to disk") |
|
31 | help="Extension of the file that should be written to disk") | |
33 |
|
32 | |||
|
33 | def _raw_format_default(self): | |||
|
34 | return 'markdown' | |||
|
35 | ||||
|
36 | def _raw_formats_default(self): | |||
|
37 | return ['md', 'markdown', 'html'] | |||
|
38 | ||||
34 | @property |
|
39 | @property | |
35 | def default_config(self): |
|
40 | def default_config(self): | |
36 | c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) |
|
41 | c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) |
@@ -1,6 +1,5 b'' | |||||
1 | """ |
|
1 | """Python script Exporter class""" | |
2 | Python exporter which exports Notebook code into a PY file. |
|
2 | ||
3 | """ |
|
|||
4 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
5 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
6 | # |
|
5 | # | |
@@ -29,3 +28,10 b' class PythonExporter(TemplateExporter):' | |||||
29 | file_extension = Unicode( |
|
28 | file_extension = Unicode( | |
30 | 'py', config=True, |
|
29 | 'py', config=True, | |
31 | help="Extension of the file that should be written to disk") |
|
30 | help="Extension of the file that should be written to disk") | |
|
31 | ||||
|
32 | def _raw_format_default(self): | |||
|
33 | return 'python' | |||
|
34 | ||||
|
35 | def _raw_formats_default(self): | |||
|
36 | return ['py', 'python'] | |||
|
37 |
@@ -1,6 +1,5 b'' | |||||
1 | """ |
|
1 | """restructuredText Exporter class""" | |
2 | Exporter for exporting notebooks to restructured text. |
|
2 | ||
3 | """ |
|
|||
4 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
5 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
6 | # |
|
5 | # | |
@@ -31,6 +30,12 b' class RSTExporter(TemplateExporter):' | |||||
31 | 'rst', config=True, |
|
30 | 'rst', config=True, | |
32 | help="Extension of the file that should be written to disk") |
|
31 | help="Extension of the file that should be written to disk") | |
33 |
|
32 | |||
|
33 | def _raw_format_default(self): | |||
|
34 | return 'rst' | |||
|
35 | ||||
|
36 | def _raw_formats_default(self): | |||
|
37 | return ['rst', 'restructuredtext'] | |||
|
38 | ||||
34 | @property |
|
39 | @property | |
35 | def default_config(self): |
|
40 | def default_config(self): | |
36 | c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) |
|
41 | c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) |
@@ -1,6 +1,4 b'' | |||||
1 | """ |
|
1 | """HTML slide show Exporter class""" | |
2 | Contains slide show exporter |
|
|||
3 | """ |
|
|||
4 |
|
2 | |||
5 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
6 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
@@ -19,16 +17,14 b' from IPython.utils.traitlets import Unicode' | |||||
19 | from IPython.nbconvert import preprocessors |
|
17 | from IPython.nbconvert import preprocessors | |
20 | from IPython.config import Config |
|
18 | from IPython.config import Config | |
21 |
|
19 | |||
22 |
from .t |
|
20 | from .html import HTMLExporter | |
23 |
|
21 | |||
24 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
25 | # Classes |
|
23 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
27 |
|
25 | |||
28 |
class SlidesExporter( |
|
26 | class SlidesExporter(HTMLExporter): | |
29 | """ |
|
27 | """Exports HTML slides with reveal.js""" | |
30 | Exports slides |
|
|||
31 | """ |
|
|||
32 |
|
28 | |||
33 | file_extension = Unicode( |
|
29 | file_extension = Unicode( | |
34 | 'slides.html', config=True, |
|
30 | 'slides.html', config=True, | |
@@ -41,15 +37,9 b' class SlidesExporter(TemplateExporter):' | |||||
41 | @property |
|
37 | @property | |
42 | def default_config(self): |
|
38 | def default_config(self): | |
43 | c = Config({ |
|
39 | c = Config({ | |
44 |
' |
|
40 | 'RevealHelpPreprocessor': { | |
45 | 'enabled':True |
|
41 | 'enabled': True, | |
46 | }, |
|
42 | }, | |
47 | 'RevealHelpPreprocessor':{ |
|
|||
48 | 'enabled':True, |
|
|||
49 | }, |
|
|||
50 | 'HighlightMagicsPreprocessor': { |
|
|||
51 | 'enabled':True |
|
|||
52 | } |
|
|||
53 | }) |
|
43 | }) | |
54 | c.merge(super(SlidesExporter,self).default_config) |
|
44 | c.merge(super(SlidesExporter,self).default_config) | |
55 | return c |
|
45 | return c |
@@ -1,4 +1,4 b'' | |||||
1 | """This module defines Exporter, a highly configurable converter |
|
1 | """This module defines TemplateExporter, a highly configurable converter | |
2 | that uses Jinja2 to export notebook files into different formats. |
|
2 | that uses Jinja2 to export notebook files into different formats. | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
@@ -126,6 +126,13 b' class TemplateExporter(Exporter):' | |||||
126 | help="""Dictionary of filters, by name and namespace, to add to the Jinja |
|
126 | help="""Dictionary of filters, by name and namespace, to add to the Jinja | |
127 | environment.""") |
|
127 | environment.""") | |
128 |
|
128 | |||
|
129 | raw_format = Unicode('') | |||
|
130 | raw_formats = List(config=True, | |||
|
131 | help="""formats of raw cells to be included in this Exporter's output.""" | |||
|
132 | ) | |||
|
133 | def _raw_formats_default(self): | |||
|
134 | return [self.raw_format] | |||
|
135 | ||||
129 |
|
136 | |||
130 | def __init__(self, config=None, extra_loaders=None, **kw): |
|
137 | def __init__(self, config=None, extra_loaders=None, **kw): | |
131 | """ |
|
138 | """ | |
@@ -202,6 +209,8 b' class TemplateExporter(Exporter):' | |||||
202 | preprocessors and filters. |
|
209 | preprocessors and filters. | |
203 | """ |
|
210 | """ | |
204 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) |
|
211 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) | |
|
212 | resources.setdefault('raw_format', self.raw_format) | |||
|
213 | resources.setdefault('raw_formats', self.raw_formats) | |||
205 |
|
214 | |||
206 | self._load_template() |
|
215 | self._load_template() | |
207 |
|
216 |
General Comments 0
You need to be logged in to leave comments.
Login now