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