Show More
@@ -1,57 +1,65 | |||
|
1 | 1 | """HTML Exporter class""" |
|
2 | 2 | |
|
3 | 3 | # Copyright (c) IPython Development Team. |
|
4 | 4 | # Distributed under the terms of the Modified BSD License. |
|
5 | 5 | |
|
6 | 6 | import os |
|
7 | 7 | |
|
8 | 8 | from IPython.nbconvert.filters.highlight import Highlight2HTML |
|
9 | 9 | from IPython.config import Config |
|
10 | 10 | |
|
11 | 11 | from .templateexporter import TemplateExporter |
|
12 | 12 | |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | # Classes |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | 17 | class HTMLExporter(TemplateExporter): |
|
18 | 18 | """ |
|
19 | 19 | Exports a basic HTML document. This exporter assists with the export of |
|
20 | 20 | HTML. Inherit from it if you are writing your own HTML template and need |
|
21 | 21 | custom preprocessors/filters. If you don't need custom preprocessors/ |
|
22 | 22 | filters, just change the 'template_file' config option. |
|
23 | 23 | """ |
|
24 | 24 | |
|
25 | 25 | def _file_extension_default(self): |
|
26 | 26 | return '.html' |
|
27 | 27 | |
|
28 | 28 | def _default_template_path_default(self): |
|
29 | 29 | return os.path.join("..", "templates", "html") |
|
30 | 30 | |
|
31 | 31 | def _template_file_default(self): |
|
32 | 32 | return 'full' |
|
33 | 33 | |
|
34 | 34 | output_mimetype = 'text/html' |
|
35 | 35 | |
|
36 | 36 | @property |
|
37 | 37 | def default_config(self): |
|
38 | 38 | c = Config({ |
|
39 | 39 | 'NbConvertBase': { |
|
40 | 'display_data_priority' : ['application/javascript', 'text/html', 'text/markdown', 'application/pdf', 'image/svg+xml', 'text/latex', 'image/png', 'image/jpeg', 'text/plain'] | |
|
40 | 'display_data_priority' : ['application/javascript', | |
|
41 | 'text/html', | |
|
42 | 'text/markdown', | |
|
43 | 'image/svg+xml', | |
|
44 | 'text/latex', | |
|
45 | 'image/png', | |
|
46 | 'image/jpeg', | |
|
47 | 'text/plain' | |
|
48 | ] | |
|
41 | 49 | }, |
|
42 | 50 | 'CSSHTMLHeaderPreprocessor':{ |
|
43 | 51 | 'enabled':True |
|
44 | 52 | }, |
|
45 | 53 | 'HighlightMagicsPreprocessor': { |
|
46 | 54 | 'enabled':True |
|
47 | 55 | } |
|
48 | 56 | }) |
|
49 | 57 | c.merge(super(HTMLExporter,self).default_config) |
|
50 | 58 | return c |
|
51 | 59 | |
|
52 | 60 | def from_notebook_node(self, nb, resources=None, **kw): |
|
53 | 61 | langinfo = nb.metadata.get('language_info', {}) |
|
54 | 62 | lexer = langinfo.get('pygments_lexer', langinfo.get('name', None)) |
|
55 | 63 | self.register_filter('highlight_code', |
|
56 | 64 | Highlight2HTML(pygments_lexer=lexer, parent=self)) |
|
57 | 65 | return super(HTMLExporter, self).from_notebook_node(nb, resources, **kw) |
General Comments 0
You need to be logged in to leave comments.
Login now