##// END OF EJS Templates
Missed a couple of dots
Thomas Kluyver -
Show More
@@ -1,96 +1,96
1 """LaTeX Exporter class"""
1 """LaTeX Exporter class"""
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
5 #
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7 #
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 # Stdlib imports
15 # Stdlib imports
16 import os
16 import os
17
17
18 # IPython imports
18 # IPython imports
19 from IPython.utils.traitlets import Unicode
19 from IPython.utils.traitlets import Unicode
20 from IPython.config import Config
20 from IPython.config import Config
21
21
22 from IPython.nbconvert.filters.highlight import Highlight2Latex
22 from IPython.nbconvert.filters.highlight import Highlight2Latex
23 from .templateexporter import TemplateExporter
23 from .templateexporter import TemplateExporter
24
24
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26 # Classes and functions
26 # Classes and functions
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29 class LatexExporter(TemplateExporter):
29 class LatexExporter(TemplateExporter):
30 """
30 """
31 Exports to a Latex template. Inherit from this class if your template is
31 Exports to a Latex template. Inherit from this class if your template is
32 LaTeX based and you need custom tranformers/filters. Inherit from it if
32 LaTeX based and you need custom tranformers/filters. Inherit from it if
33 you are writing your own HTML template and need custom tranformers/filters.
33 you are writing your own HTML template and need custom tranformers/filters.
34 If you don't need custom tranformers/filters, just change the
34 If you don't need custom tranformers/filters, just change the
35 'template_file' config option. Place your template in the special "/latex"
35 'template_file' config option. Place your template in the special "/latex"
36 subfolder of the "../templates" folder.
36 subfolder of the "../templates" folder.
37 """
37 """
38
38
39 def _file_extension_default(self):
39 def _file_extension_default(self):
40 return 'tex'
40 return '.tex'
41
41
42 def _template_file_default(self):
42 def _template_file_default(self):
43 return 'article'
43 return 'article'
44
44
45 #Latex constants
45 #Latex constants
46 def _default_template_path_default(self):
46 def _default_template_path_default(self):
47 return os.path.join("..", "templates", "latex")
47 return os.path.join("..", "templates", "latex")
48
48
49 def _template_skeleton_path_default(self):
49 def _template_skeleton_path_default(self):
50 return os.path.join("..", "templates", "latex", "skeleton")
50 return os.path.join("..", "templates", "latex", "skeleton")
51
51
52 #Special Jinja2 syntax that will not conflict when exporting latex.
52 #Special Jinja2 syntax that will not conflict when exporting latex.
53 jinja_comment_block_start = Unicode("((=", config=True)
53 jinja_comment_block_start = Unicode("((=", config=True)
54 jinja_comment_block_end = Unicode("=))", config=True)
54 jinja_comment_block_end = Unicode("=))", config=True)
55 jinja_variable_block_start = Unicode("(((", config=True)
55 jinja_variable_block_start = Unicode("(((", config=True)
56 jinja_variable_block_end = Unicode(")))", config=True)
56 jinja_variable_block_end = Unicode(")))", config=True)
57 jinja_logic_block_start = Unicode("((*", config=True)
57 jinja_logic_block_start = Unicode("((*", config=True)
58 jinja_logic_block_end = Unicode("*))", config=True)
58 jinja_logic_block_end = Unicode("*))", config=True)
59
59
60 #Extension that the template files use.
60 #Extension that the template files use.
61 template_extension = Unicode(".tplx", config=True)
61 template_extension = Unicode(".tplx", config=True)
62
62
63 output_mimetype = 'text/latex'
63 output_mimetype = 'text/latex'
64
64
65
65
66 @property
66 @property
67 def default_config(self):
67 def default_config(self):
68 c = Config({
68 c = Config({
69 'NbConvertBase': {
69 'NbConvertBase': {
70 'display_data_priority' : ['text/latex', 'application/pdf', 'image/png', 'image/jpeg', 'image/svg+xml', 'text/plain']
70 'display_data_priority' : ['text/latex', 'application/pdf', 'image/png', 'image/jpeg', 'image/svg+xml', 'text/plain']
71 },
71 },
72 'ExtractOutputPreprocessor': {
72 'ExtractOutputPreprocessor': {
73 'enabled':True
73 'enabled':True
74 },
74 },
75 'SVG2PDFPreprocessor': {
75 'SVG2PDFPreprocessor': {
76 'enabled':True
76 'enabled':True
77 },
77 },
78 'LatexPreprocessor': {
78 'LatexPreprocessor': {
79 'enabled':True
79 'enabled':True
80 },
80 },
81 'SphinxPreprocessor': {
81 'SphinxPreprocessor': {
82 'enabled':True
82 'enabled':True
83 },
83 },
84 'HighlightMagicsPreprocessor': {
84 'HighlightMagicsPreprocessor': {
85 'enabled':True
85 'enabled':True
86 }
86 }
87 })
87 })
88 c.merge(super(LatexExporter,self).default_config)
88 c.merge(super(LatexExporter,self).default_config)
89 return c
89 return c
90
90
91 def from_notebook_node(self, nb, resources=None, **kw):
91 def from_notebook_node(self, nb, resources=None, **kw):
92 langinfo = nb.metadata.get('language_info', {})
92 langinfo = nb.metadata.get('language_info', {})
93 lexer = langinfo.get('pygments_lexer', langinfo.get('name', None))
93 lexer = langinfo.get('pygments_lexer', langinfo.get('name', None))
94 self.register_filter('highlight_code',
94 self.register_filter('highlight_code',
95 Highlight2Latex(pygments_lexer=lexer, parent=self))
95 Highlight2Latex(pygments_lexer=lexer, parent=self))
96 return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
96 return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
@@ -1,43 +1,43
1 """HTML slide show Exporter class"""
1 """HTML slide show Exporter class"""
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
5 #
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7 #
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 from IPython.nbconvert import preprocessors
15 from IPython.nbconvert import preprocessors
16 from IPython.config import Config
16 from IPython.config import Config
17
17
18 from .html import HTMLExporter
18 from .html import HTMLExporter
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Classes
21 # Classes
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 class SlidesExporter(HTMLExporter):
24 class SlidesExporter(HTMLExporter):
25 """Exports HTML slides with reveal.js"""
25 """Exports HTML slides with reveal.js"""
26
26
27 def _file_extension_default(self):
27 def _file_extension_default(self):
28 return 'slides.html'
28 return '.slides.html'
29
29
30 def _template_file_default(self):
30 def _template_file_default(self):
31 return 'slides_reveal'
31 return 'slides_reveal'
32
32
33 output_mimetype = 'text/html'
33 output_mimetype = 'text/html'
34
34
35 @property
35 @property
36 def default_config(self):
36 def default_config(self):
37 c = Config({
37 c = Config({
38 'RevealHelpPreprocessor': {
38 'RevealHelpPreprocessor': {
39 'enabled': True,
39 'enabled': True,
40 },
40 },
41 })
41 })
42 c.merge(super(SlidesExporter,self).default_config)
42 c.merge(super(SlidesExporter,self).default_config)
43 return c
43 return c
General Comments 0
You need to be logged in to leave comments. Login now