diff --git a/IPython/html/nbconvert/handlers.py b/IPython/html/nbconvert/handlers.py
index f173209..02e31d5 100644
--- a/IPython/html/nbconvert/handlers.py
+++ b/IPython/html/nbconvert/handlers.py
@@ -36,8 +36,9 @@ class NbconvertFileHandler(IPythonHandler):
'attachment; filename="%s"' % filename)
# MIME type
- if exporter.mime_type:
- self.set_header('Content-Type', '%s; charset=utf-8' % exporter.mime_type)
+ if exporter.output_mimetype:
+ self.set_header('Content-Type',
+ '%s; charset=utf-8' % exporter.output_mimetype)
output, resources = exporter.from_filename(os_path)
@@ -57,8 +58,9 @@ class NbconvertPostHandler(IPythonHandler):
nbnode = to_notebook_json(model['content'])
# MIME type
- if exporter.mime_type:
- self.set_header('Content-Type', '%s; charset=utf-8' % exporter.mime_type)
+ if exporter.output_mimetype:
+ self.set_header('Content-Type',
+ '%s; charset=utf-8' % exporter.output_mimetype)
output, resources = exporter.from_notebook_node(nbnode)
diff --git a/IPython/html/static/notebook/js/celltoolbarpresets/rawcell.js b/IPython/html/static/notebook/js/celltoolbarpresets/rawcell.js
index 3d51798..75965f0 100644
--- a/IPython/html/static/notebook/js/celltoolbarpresets/rawcell.js
+++ b/IPython/html/static/notebook/js/celltoolbarpresets/rawcell.js
@@ -22,7 +22,7 @@
["reST", "text/restructuredtext"],
["HTML", "text/html"],
["Markdown", "text/markdown"],
- ["Python", "application/x-python"],
+ ["Python", "text/x-python"],
["Custom", "dialog"],
],
@@ -87,4 +87,4 @@
CellToolbar.register_preset('Raw Cell Format', raw_cell_preset);
console.log('Raw Cell Format toolbar preset loaded.');
-}(IPython));
\ No newline at end of file
+}(IPython));
diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py
index c7c60d0..26e1fe4 100644
--- a/IPython/nbconvert/exporters/exporter.py
+++ b/IPython/nbconvert/exporters/exporter.py
@@ -53,7 +53,7 @@ class Exporter(LoggingConfigurable):
help="Extension of the file that should be written to disk"
)
- mime_type = Unicode('', config=True,
+ output_mimetype = Unicode('', config=True,
help="MIME type of the result file, for HTTP response headers."
)
diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py
index 3a9147c..95790c1 100644
--- a/IPython/nbconvert/exporters/html.py
+++ b/IPython/nbconvert/exporters/html.py
@@ -43,7 +43,7 @@ class HTMLExporter(TemplateExporter):
default_template = Unicode('full', config=True, help="""Flavor of the data
format to use. I.E. 'full' or 'basic'""")
- def _raw_mimetype_default(self):
+ def _output_mimetype_default(self):
return 'text/html'
@property
diff --git a/IPython/nbconvert/exporters/latex.py b/IPython/nbconvert/exporters/latex.py
index 369dcf5..551e535 100644
--- a/IPython/nbconvert/exporters/latex.py
+++ b/IPython/nbconvert/exporters/latex.py
@@ -40,10 +40,6 @@ class LatexExporter(TemplateExporter):
'tex', config=True,
help="Extension of the file that should be written to disk")
- mime_type = Unicode('application/x-tex', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
-
default_template = Unicode('article', config=True, help="""Template of the
data format to use. I.E. 'article' or 'report'""")
@@ -67,7 +63,7 @@ class LatexExporter(TemplateExporter):
#Extension that the template files use.
template_extension = Unicode(".tplx", config=True)
- def _raw_mimetype_default(self):
+ def _output_mimetype_default(self):
return 'text/latex'
diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py
index da4900b..4013c3f 100644
--- a/IPython/nbconvert/exporters/markdown.py
+++ b/IPython/nbconvert/exporters/markdown.py
@@ -30,15 +30,11 @@ class MarkdownExporter(TemplateExporter):
'md', config=True,
help="Extension of the file that should be written to disk")
- def _raw_mimetype_default(self):
+ def _output_mimetype_default(self):
return 'text/markdown'
def _raw_mimetypes_default(self):
- return ['text/markdown', 'text/html']
-
- mime_type = Unicode('text/x-markdown', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
+ return ['text/markdown', 'text/html', '']
@property
def default_config(self):
diff --git a/IPython/nbconvert/exporters/python.py b/IPython/nbconvert/exporters/python.py
index d618cd7..750b0ac 100644
--- a/IPython/nbconvert/exporters/python.py
+++ b/IPython/nbconvert/exporters/python.py
@@ -29,9 +29,5 @@ class PythonExporter(TemplateExporter):
'py', config=True,
help="Extension of the file that should be written to disk")
- def _raw_mimetype_default(self):
- return 'application/x-python'
-
- mime_type = Unicode('text/x-python', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
+ def _output_mimetype_default(self):
+ return 'text/x-python'
diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py
index 34b9eca..0bf4ead 100644
--- a/IPython/nbconvert/exporters/rst.py
+++ b/IPython/nbconvert/exporters/rst.py
@@ -30,13 +30,9 @@ class RSTExporter(TemplateExporter):
'rst', config=True,
help="Extension of the file that should be written to disk")
- def _raw_mimetype_default(self):
+ def _output_mimetype_default(self):
return 'text/restructuredtext'
- mime_type = Unicode('text/x-rst', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
-
@property
def default_config(self):
c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
diff --git a/IPython/nbconvert/exporters/slides.py b/IPython/nbconvert/exporters/slides.py
index 7f8ab46..6b59e00 100644
--- a/IPython/nbconvert/exporters/slides.py
+++ b/IPython/nbconvert/exporters/slides.py
@@ -31,9 +31,8 @@ class SlidesExporter(HTMLExporter):
help="Extension of the file that should be written to disk"
)
- mime_type = Unicode('text/html', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
+ def _output_mimetype_default(self):
+ return 'text/html'
default_template = Unicode('reveal', config=True, help="""Template of the
data format to use. I.E. 'reveal'""")
diff --git a/IPython/nbconvert/exporters/templateexporter.py b/IPython/nbconvert/exporters/templateexporter.py
index a5eed82..cdc1ee6 100644
--- a/IPython/nbconvert/exporters/templateexporter.py
+++ b/IPython/nbconvert/exporters/templateexporter.py
@@ -126,12 +126,13 @@ class TemplateExporter(Exporter):
help="""Dictionary of filters, by name and namespace, to add to the Jinja
environment.""")
- raw_mimetype = Unicode('')
+ output_mimetype = Unicode('')
+
raw_mimetypes = List(config=True,
help="""formats of raw cells to be included in this Exporter's output."""
)
def _raw_mimetypes_default(self):
- return [self.raw_mimetype]
+ return [self.output_mimetype, '']
def __init__(self, config=None, extra_loaders=None, **kw):
@@ -209,7 +210,6 @@ class TemplateExporter(Exporter):
preprocessors and filters.
"""
nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
- resources.setdefault('raw_mimetype', self.raw_mimetype)
resources.setdefault('raw_mimetypes', self.raw_mimetypes)
self._load_template()
diff --git a/IPython/nbconvert/exporters/tests/base.py b/IPython/nbconvert/exporters/tests/base.py
index 9db1caa..ad61321 100644
--- a/IPython/nbconvert/exporters/tests/base.py
+++ b/IPython/nbconvert/exporters/tests/base.py
@@ -23,7 +23,7 @@ from ...tests.base import TestsBase
#-----------------------------------------------------------------------------
all_raw_mimetypes = {
- 'application/x-python',
+ 'text/x-python',
'text/markdown',
'text/html',
'text/restructuredtext',
diff --git a/IPython/nbconvert/exporters/tests/files/rawtest.ipynb b/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
index 667ddbf..6eae33a 100644
--- a/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
+++ b/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
@@ -43,7 +43,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_mimetype": "application/x-python"
+ "raw_mimetype": "text/x-python"
},
"source": [
"def bar():\n",
@@ -81,4 +81,4 @@
"metadata": {}
}
]
-}
\ No newline at end of file
+}
diff --git a/IPython/nbconvert/templates/latex/skeleton/null.tplx b/IPython/nbconvert/templates/latex/skeleton/null.tplx
index 5f8909b..2327e84 100644
--- a/IPython/nbconvert/templates/latex/skeleton/null.tplx
+++ b/IPython/nbconvert/templates/latex/skeleton/null.tplx
@@ -81,7 +81,7 @@ consider calling super even if it is a leave block, we might insert more blocks
((*- endblock headingcell -*))
((*- elif cell.cell_type in ['raw'] -*))
((*- block rawcell scoped -*))
- ((* if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype')) == resources.get('raw_mimetype') *))
+ ((* if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) *))
((( cell.source )))
((* endif *))
((*- endblock rawcell -*))
diff --git a/IPython/nbconvert/templates/skeleton/null.tpl b/IPython/nbconvert/templates/skeleton/null.tpl
index aec85f4..9779043 100644
--- a/IPython/nbconvert/templates/skeleton/null.tpl
+++ b/IPython/nbconvert/templates/skeleton/null.tpl
@@ -77,7 +77,7 @@ consider calling super even if it is a leave block, we might insert more blocks
{%- endblock headingcell -%}
{%- elif cell.cell_type in ['raw'] -%}
{%- block rawcell scoped -%}
- {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
+ {% if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
{{ cell.source }}
{% endif %}
{%- endblock rawcell -%}