##// END OF EJS Templates
add raw_format to Exporter classes...
MinRK -
Show More
@@ -1,5 +1,5 b''
1 """This module defines Exporter, a highly configurable converter
2 that uses Jinja2 to export notebook files into different formats.
1 """This module defines a base Exporter class. For Jinja template-based export,
2 see templateexporter.py.
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
@@ -1,6 +1,4 b''
1 """
2 Exporter that exports Basic HTML.
3 """
1 """HTML Exporter class"""
4 2
5 3 #-----------------------------------------------------------------------------
6 4 # Copyright (c) 2013, the IPython Development Team.
@@ -41,6 +39,9 b' class HTMLExporter(TemplateExporter):'
41 39 default_template = Unicode('full', config=True, help="""Flavor of the data
42 40 format to use. I.E. 'full' or 'basic'""")
43 41
42 def _raw_format_default(self):
43 return 'html'
44
44 45 @property
45 46 def default_config(self):
46 47 c = Config({
@@ -1,9 +1,5 b''
1 """
2 Exporter that allows Latex Jinja templates to work. Contains logic to
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 """
1 """LaTeX Exporter class"""
2
7 3 #-----------------------------------------------------------------------------
8 4 # Copyright (c) 2013, the IPython Development Team.
9 5 #
@@ -67,6 +63,9 b' class LatexExporter(TemplateExporter):'
67 63 #Extension that the template files use.
68 64 template_extension = Unicode(".tplx", config=True)
69 65
66 def _raw_format_default(self):
67 return 'latex'
68
70 69
71 70 @property
72 71 def default_config(self):
@@ -1,6 +1,5 b''
1 """
2 Exporter that will export your ipynb to Markdown.
3 """
1 """Markdown Exporter class"""
2
4 3 #-----------------------------------------------------------------------------
5 4 # Copyright (c) 2013, the IPython Development Team.
6 5 #
@@ -31,6 +30,12 b' class MarkdownExporter(TemplateExporter):'
31 30 'md', config=True,
32 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 39 @property
35 40 def default_config(self):
36 41 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
@@ -1,6 +1,5 b''
1 """
2 Python exporter which exports Notebook code into a PY file.
3 """
1 """Python script Exporter class"""
2
4 3 #-----------------------------------------------------------------------------
5 4 # Copyright (c) 2013, the IPython Development Team.
6 5 #
@@ -29,3 +28,10 b' class PythonExporter(TemplateExporter):'
29 28 file_extension = Unicode(
30 29 'py', config=True,
31 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 """
2 Exporter for exporting notebooks to restructured text.
3 """
1 """restructuredText Exporter class"""
2
4 3 #-----------------------------------------------------------------------------
5 4 # Copyright (c) 2013, the IPython Development Team.
6 5 #
@@ -31,6 +30,12 b' class RSTExporter(TemplateExporter):'
31 30 'rst', config=True,
32 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 39 @property
35 40 def default_config(self):
36 41 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
@@ -1,6 +1,4 b''
1 """
2 Contains slide show exporter
3 """
1 """HTML slide show Exporter class"""
4 2
5 3 #-----------------------------------------------------------------------------
6 4 # Copyright (c) 2013, the IPython Development Team.
@@ -19,16 +17,14 b' from IPython.utils.traitlets import Unicode'
19 17 from IPython.nbconvert import preprocessors
20 18 from IPython.config import Config
21 19
22 from .templateexporter import TemplateExporter
20 from .html import HTMLExporter
23 21
24 22 #-----------------------------------------------------------------------------
25 23 # Classes
26 24 #-----------------------------------------------------------------------------
27 25
28 class SlidesExporter(TemplateExporter):
29 """
30 Exports slides
31 """
26 class SlidesExporter(HTMLExporter):
27 """Exports HTML slides with reveal.js"""
32 28
33 29 file_extension = Unicode(
34 30 'slides.html', config=True,
@@ -41,15 +37,9 b' class SlidesExporter(TemplateExporter):'
41 37 @property
42 38 def default_config(self):
43 39 c = Config({
44 'CSSHTMLHeaderPreprocessor':{
45 'enabled':True
46 },
47 40 'RevealHelpPreprocessor':{
48 41 'enabled':True,
49 42 },
50 'HighlightMagicsPreprocessor': {
51 'enabled':True
52 }
53 43 })
54 44 c.merge(super(SlidesExporter,self).default_config)
55 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 2 that uses Jinja2 to export notebook files into different formats.
3 3 """
4 4
@@ -126,6 +126,13 b' class TemplateExporter(Exporter):'
126 126 help="""Dictionary of filters, by name and namespace, to add to the Jinja
127 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 137 def __init__(self, config=None, extra_loaders=None, **kw):
131 138 """
@@ -202,6 +209,8 b' class TemplateExporter(Exporter):'
202 209 preprocessors and filters.
203 210 """
204 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 215 self._load_template()
207 216
General Comments 0
You need to be logged in to leave comments. Login now