Show More
@@ -36,8 +36,9 b' class NbconvertFileHandler(IPythonHandler):' | |||
|
36 | 36 | 'attachment; filename="%s"' % filename) |
|
37 | 37 | |
|
38 | 38 | # MIME type |
|
39 |
if exporter.mime |
|
|
40 |
self.set_header('Content-Type', |
|
|
39 | if exporter.output_mimetype: | |
|
40 | self.set_header('Content-Type', | |
|
41 | '%s; charset=utf-8' % exporter.output_mimetype) | |
|
41 | 42 | |
|
42 | 43 | output, resources = exporter.from_filename(os_path) |
|
43 | 44 | |
@@ -57,8 +58,9 b' class NbconvertPostHandler(IPythonHandler):' | |||
|
57 | 58 | nbnode = to_notebook_json(model['content']) |
|
58 | 59 | |
|
59 | 60 | # MIME type |
|
60 |
if exporter.mime |
|
|
61 |
self.set_header('Content-Type', |
|
|
61 | if exporter.output_mimetype: | |
|
62 | self.set_header('Content-Type', | |
|
63 | '%s; charset=utf-8' % exporter.output_mimetype) | |
|
62 | 64 | |
|
63 | 65 | output, resources = exporter.from_notebook_node(nbnode) |
|
64 | 66 |
@@ -22,7 +22,7 b'' | |||
|
22 | 22 | ["reST", "text/restructuredtext"], |
|
23 | 23 | ["HTML", "text/html"], |
|
24 | 24 | ["Markdown", "text/markdown"], |
|
25 |
["Python", " |
|
|
25 | ["Python", "text/x-python"], | |
|
26 | 26 | ["Custom", "dialog"], |
|
27 | 27 | |
|
28 | 28 | ], |
@@ -87,4 +87,4 b'' | |||
|
87 | 87 | CellToolbar.register_preset('Raw Cell Format', raw_cell_preset); |
|
88 | 88 | console.log('Raw Cell Format toolbar preset loaded.'); |
|
89 | 89 | |
|
90 | }(IPython)); No newline at end of file | |
|
90 | }(IPython)); |
@@ -53,7 +53,7 b' class Exporter(LoggingConfigurable):' | |||
|
53 | 53 | help="Extension of the file that should be written to disk" |
|
54 | 54 | ) |
|
55 | 55 | |
|
56 |
mime |
|
|
56 | output_mimetype = Unicode('', config=True, | |
|
57 | 57 | help="MIME type of the result file, for HTTP response headers." |
|
58 | 58 | ) |
|
59 | 59 |
@@ -43,7 +43,7 b' class HTMLExporter(TemplateExporter):' | |||
|
43 | 43 | default_template = Unicode('full', config=True, help="""Flavor of the data |
|
44 | 44 | format to use. I.E. 'full' or 'basic'""") |
|
45 | 45 | |
|
46 |
def _ |
|
|
46 | def _output_mimetype_default(self): | |
|
47 | 47 | return 'text/html' |
|
48 | 48 | |
|
49 | 49 | @property |
@@ -40,10 +40,6 b' class LatexExporter(TemplateExporter):' | |||
|
40 | 40 | 'tex', config=True, |
|
41 | 41 | help="Extension of the file that should be written to disk") |
|
42 | 42 | |
|
43 | mime_type = Unicode('application/x-tex', config=True, | |
|
44 | help="MIME type of the result file, for HTTP response headers." | |
|
45 | ) | |
|
46 | ||
|
47 | 43 | default_template = Unicode('article', config=True, help="""Template of the |
|
48 | 44 | data format to use. I.E. 'article' or 'report'""") |
|
49 | 45 | |
@@ -67,7 +63,7 b' class LatexExporter(TemplateExporter):' | |||
|
67 | 63 | #Extension that the template files use. |
|
68 | 64 | template_extension = Unicode(".tplx", config=True) |
|
69 | 65 | |
|
70 |
def _ |
|
|
66 | def _output_mimetype_default(self): | |
|
71 | 67 | return 'text/latex' |
|
72 | 68 | |
|
73 | 69 |
@@ -30,15 +30,11 b' class MarkdownExporter(TemplateExporter):' | |||
|
30 | 30 | 'md', config=True, |
|
31 | 31 | help="Extension of the file that should be written to disk") |
|
32 | 32 | |
|
33 |
def _ |
|
|
33 | def _output_mimetype_default(self): | |
|
34 | 34 | return 'text/markdown' |
|
35 | 35 | |
|
36 | 36 | def _raw_mimetypes_default(self): |
|
37 | return ['text/markdown', 'text/html'] | |
|
38 | ||
|
39 | mime_type = Unicode('text/x-markdown', config=True, | |
|
40 | help="MIME type of the result file, for HTTP response headers." | |
|
41 | ) | |
|
37 | return ['text/markdown', 'text/html', ''] | |
|
42 | 38 | |
|
43 | 39 | @property |
|
44 | 40 | def default_config(self): |
@@ -29,9 +29,5 b' class PythonExporter(TemplateExporter):' | |||
|
29 | 29 | 'py', config=True, |
|
30 | 30 | help="Extension of the file that should be written to disk") |
|
31 | 31 | |
|
32 |
def _ |
|
|
33 |
return ' |
|
|
34 | ||
|
35 | mime_type = Unicode('text/x-python', config=True, | |
|
36 | help="MIME type of the result file, for HTTP response headers." | |
|
37 | ) | |
|
32 | def _output_mimetype_default(self): | |
|
33 | return 'text/x-python' |
@@ -30,13 +30,9 b' class RSTExporter(TemplateExporter):' | |||
|
30 | 30 | 'rst', config=True, |
|
31 | 31 | help="Extension of the file that should be written to disk") |
|
32 | 32 | |
|
33 |
def _ |
|
|
33 | def _output_mimetype_default(self): | |
|
34 | 34 | return 'text/restructuredtext' |
|
35 | 35 | |
|
36 | mime_type = Unicode('text/x-rst', config=True, | |
|
37 | help="MIME type of the result file, for HTTP response headers." | |
|
38 | ) | |
|
39 | ||
|
40 | 36 | @property |
|
41 | 37 | def default_config(self): |
|
42 | 38 | c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) |
@@ -31,9 +31,8 b' class SlidesExporter(HTMLExporter):' | |||
|
31 | 31 | help="Extension of the file that should be written to disk" |
|
32 | 32 | ) |
|
33 | 33 | |
|
34 | mime_type = Unicode('text/html', config=True, | |
|
35 | help="MIME type of the result file, for HTTP response headers." | |
|
36 | ) | |
|
34 | def _output_mimetype_default(self): | |
|
35 | return 'text/html' | |
|
37 | 36 | |
|
38 | 37 | default_template = Unicode('reveal', config=True, help="""Template of the |
|
39 | 38 | data format to use. I.E. 'reveal'""") |
@@ -126,12 +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 |
|
|
|
129 | output_mimetype = Unicode('') | |
|
130 | ||
|
130 | 131 | raw_mimetypes = List(config=True, |
|
131 | 132 | help="""formats of raw cells to be included in this Exporter's output.""" |
|
132 | 133 | ) |
|
133 | 134 | def _raw_mimetypes_default(self): |
|
134 |
return [self. |
|
|
135 | return [self.output_mimetype, ''] | |
|
135 | 136 | |
|
136 | 137 | |
|
137 | 138 | def __init__(self, config=None, extra_loaders=None, **kw): |
@@ -209,7 +210,6 b' class TemplateExporter(Exporter):' | |||
|
209 | 210 | preprocessors and filters. |
|
210 | 211 | """ |
|
211 | 212 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) |
|
212 | resources.setdefault('raw_mimetype', self.raw_mimetype) | |
|
213 | 213 | resources.setdefault('raw_mimetypes', self.raw_mimetypes) |
|
214 | 214 | |
|
215 | 215 | self._load_template() |
@@ -23,7 +23,7 b' from ...tests.base import TestsBase' | |||
|
23 | 23 | #----------------------------------------------------------------------------- |
|
24 | 24 | |
|
25 | 25 | all_raw_mimetypes = { |
|
26 |
' |
|
|
26 | 'text/x-python', | |
|
27 | 27 | 'text/markdown', |
|
28 | 28 | 'text/html', |
|
29 | 29 | 'text/restructuredtext', |
@@ -43,7 +43,7 b'' | |||
|
43 | 43 | { |
|
44 | 44 | "cell_type": "raw", |
|
45 | 45 | "metadata": { |
|
46 |
"raw_mimetype": " |
|
|
46 | "raw_mimetype": "text/x-python" | |
|
47 | 47 | }, |
|
48 | 48 | "source": [ |
|
49 | 49 | "def bar():\n", |
@@ -81,4 +81,4 b'' | |||
|
81 | 81 | "metadata": {} |
|
82 | 82 | } |
|
83 | 83 | ] |
|
84 | } No newline at end of file | |
|
84 | } |
@@ -81,7 +81,7 b' consider calling super even if it is a leave block, we might insert more blocks ' | |||
|
81 | 81 | ((*- endblock headingcell -*)) |
|
82 | 82 | ((*- elif cell.cell_type in ['raw'] -*)) |
|
83 | 83 | ((*- block rawcell scoped -*)) |
|
84 |
((* if cell.metadata.get('raw_mimetype', |
|
|
84 | ((* if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) *)) | |
|
85 | 85 | ((( cell.source ))) |
|
86 | 86 | ((* endif *)) |
|
87 | 87 | ((*- endblock rawcell -*)) |
@@ -77,7 +77,7 b' consider calling super even if it is a leave block, we might insert more blocks ' | |||
|
77 | 77 | {%- endblock headingcell -%} |
|
78 | 78 | {%- elif cell.cell_type in ['raw'] -%} |
|
79 | 79 | {%- block rawcell scoped -%} |
|
80 |
{% if cell.metadata.get('raw_mimetype', |
|
|
80 | {% if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %} | |
|
81 | 81 | {{ cell.source }} |
|
82 | 82 | {% endif %} |
|
83 | 83 | {%- endblock rawcell -%} |
General Comments 0
You need to be logged in to leave comments.
Login now