##// END OF EJS Templates
HTML-Slides -> Slides-Reveal
Jonathan Frederic -
Show More
@@ -0,0 +1,52 b''
1 """
2 Exporter that exports Basic HTML.
3 """
4
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
7 #
8 # Distributed under the terms of the Modified BSD License.
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
12
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16
17 from IPython.utils.traitlets import Unicode
18
19 from IPython.nbconvert import transformers
20 from IPython.config import Config
21
22 from .exporter import Exporter
23
24 #-----------------------------------------------------------------------------
25 # Classes
26 #-----------------------------------------------------------------------------
27
28 class SlidesExporter(Exporter):
29 """
30 Exports slides
31 """
32
33 file_extension = Unicode(
34 'html', config=True,
35 help="Extension of the file that should be written to disk"
36 )
37
38 flavor = Unicode('reveal', config=True, help="""Flavor of the data format to
39 use. I.E. 'reveal'""")
40
41 @property
42 def default_config(self):
43 c = Config({
44 'CSSHTMLHeaderTransformer':{
45 'enabled':True
46 },
47 'RevealHelpTransformer':{
48 'enabled':True,
49 },
50 })
51 c.merge(super(SlidesExporter,self).default_config)
52 return c
@@ -0,0 +1,47 b''
1 """
2 Module with tests for slides.py
3 """
4
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
7 #
8 # Distributed under the terms of the Modified BSD License.
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
12
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16
17 from .base import ExportersTestsBase
18 from ..slides import SlidesExporter
19
20 #-----------------------------------------------------------------------------
21 # Class
22 #-----------------------------------------------------------------------------
23
24 class TestSlidesExporter(ExportersTestsBase):
25 """Contains test functions for slides.py"""
26
27 def test_constructor(self):
28 """
29 Can a SlidesExporter be constructed?
30 """
31 SlidesExporter()
32
33
34 def test_export(self):
35 """
36 Can a SlidesExporter export something?
37 """
38 (output, resources) = SlidesExporter().from_filename(self._get_notebook())
39 assert len(output) > 0
40
41
42 def test_export_reveal(self):
43 """
44 Can a SlidesExporter export using the 'reveal' flavor?
45 """
46 (output, resources) = SlidesExporter(flavor='reveal').from_filename(self._get_notebook())
47 assert len(output) > 0
@@ -1,5 +1,6 b''
1 from .html import HTMLExporter
2 from .export import *
1 from .export import *
2 from .html import HTMLExporter
3 from .slides import SlidesExporter
3 from .exporter import Exporter
4 from .exporter import Exporter
4 from .latex import LatexExporter
5 from .latex import LatexExporter
5 from .markdown import MarkdownExporter
6 from .markdown import MarkdownExporter
@@ -20,6 +20,7 b' from IPython.config import Config'
20
20
21 from .exporter import Exporter
21 from .exporter import Exporter
22 from .html import HTMLExporter
22 from .html import HTMLExporter
23 from .slides import SlidesExporter
23 from .latex import LatexExporter
24 from .latex import LatexExporter
24 from .markdown import MarkdownExporter
25 from .markdown import MarkdownExporter
25 from .python import PythonExporter
26 from .python import PythonExporter
@@ -67,6 +68,7 b' __all__ = ['
67 'export',
68 'export',
68 'export_html',
69 'export_html',
69 'export_custom',
70 'export_custom',
71 'export_slides',
70 'export_latex',
72 'export_latex',
71 'export_markdown',
73 'export_markdown',
72 'export_python',
74 'export_python',
@@ -135,6 +137,14 b' def export_html(nb, **kw):'
135
137
136
138
137 @DocDecorator
139 @DocDecorator
140 def export_slides(nb, **kw):
141 """
142 Export a notebook object to Slides
143 """
144 return export(SlidesExporter, nb, **kw)
145
146
147 @DocDecorator
138 def export_latex(nb, **kw):
148 def export_latex(nb, **kw):
139 """
149 """
140 Export a notebook object to LaTeX
150 Export a notebook object to LaTeX
@@ -1,5 +1,5 b''
1 """
1 """
2 Module with tests for basichtml.py
2 Module with tests for html.py
3 """
3 """
4
4
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
@@ -23,7 +23,7 b' from IPython.testing.decorators import onlyif_cmds_exist'
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class TestHTMLExporter(ExportersTestsBase):
25 class TestHTMLExporter(ExportersTestsBase):
26 """Contains test functions for basichtml.py"""
26 """Contains test functions for html.py"""
27
27
28 def test_constructor(self):
28 def test_constructor(self):
29 """
29 """
@@ -54,11 +54,3 b' class TestHTMLExporter(ExportersTestsBase):'
54 """
54 """
55 (output, resources) = HTMLExporter(flavor='full').from_filename(self._get_notebook())
55 (output, resources) = HTMLExporter(flavor='full').from_filename(self._get_notebook())
56 assert len(output) > 0
56 assert len(output) > 0
57
58
59 def test_export_reveal(self):
60 """
61 Can a HTMLExporter export using the 'reveal' flavor?
62 """
63 (output, resources) = HTMLExporter(flavor='reveal').from_filename(self._get_notebook())
64 assert len(output) > 0 No newline at end of file
@@ -96,8 +96,8 b' class NbConvertApp(BaseIPythonApplication):'
96 > ipython nbconvert --to latex mynotebook.ipnynb
96 > ipython nbconvert --to latex mynotebook.ipnynb
97
97
98 Both HTML and LaTeX support multiple flavors of output. LaTeX includes
98 Both HTML and LaTeX support multiple flavors of output. LaTeX includes
99 'basic', 'book', and 'article'. HTML includes 'basic', 'full', and
99 'basic', 'book', and 'article'. HTML includes 'basic' and 'full'. You
100 'reveal'. You can specify the flavor of the format used.
100 can specify the flavor of the format used.
101
101
102 > ipython nbconvert --to html --flavor reveal mynotebook.ipnynb
102 > ipython nbconvert --to html --flavor reveal mynotebook.ipnynb
103
103
1 NO CONTENT: file renamed from IPython/nbconvert/templates/html_reveal.tpl to IPython/nbconvert/templates/slides_reveal.tpl
NO CONTENT: file renamed from IPython/nbconvert/templates/html_reveal.tpl to IPython/nbconvert/templates/slides_reveal.tpl
@@ -82,10 +82,10 b' class TestNbConvertApp(TestsBase):'
82
82
83 def test_flavor(self):
83 def test_flavor(self):
84 """
84 """
85 Do explicit notebook names work?
85 Do export flavors work?
86 """
86 """
87 with self.create_temp_cwd(['notebook*.ipynb']):
87 with self.create_temp_cwd(['notebook*.ipynb']):
88 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="html"',
88 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="slides"',
89 '--notebooks=["notebook2.ipynb"]', '--flavor="reveal"']).lower()
89 '--notebooks=["notebook2.ipynb"]', '--flavor="reveal"']).lower()
90 assert os.path.isfile('notebook2.html')
90 assert os.path.isfile('notebook2.html')
91 with open('notebook2.html') as f:
91 with open('notebook2.html') as f:
General Comments 0
You need to be logged in to leave comments. Login now