diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py
index 71b9e01..bb63397 100644
--- a/IPython/nbconvert/exporters/html.py
+++ b/IPython/nbconvert/exporters/html.py
@@ -39,8 +39,8 @@ class HTMLExporter(TemplateExporter):
default_template = Unicode('full', config=True, help="""Flavor of the data
format to use. I.E. 'full' or 'basic'""")
- def _raw_format_default(self):
- return 'html'
+ def _raw_mimetype_default(self):
+ return 'text/html'
@property
def default_config(self):
diff --git a/IPython/nbconvert/exporters/latex.py b/IPython/nbconvert/exporters/latex.py
index 8576295..a095262 100644
--- a/IPython/nbconvert/exporters/latex.py
+++ b/IPython/nbconvert/exporters/latex.py
@@ -63,8 +63,8 @@ class LatexExporter(TemplateExporter):
#Extension that the template files use.
template_extension = Unicode(".tplx", config=True)
- def _raw_format_default(self):
- return 'latex'
+ def _raw_mimetype_default(self):
+ return 'text/latex'
@property
diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py
index 56334c7..fb38539 100644
--- a/IPython/nbconvert/exporters/markdown.py
+++ b/IPython/nbconvert/exporters/markdown.py
@@ -30,11 +30,11 @@ class MarkdownExporter(TemplateExporter):
'md', config=True,
help="Extension of the file that should be written to disk")
- def _raw_format_default(self):
- return 'markdown'
+ def _raw_mimetype_default(self):
+ return 'text/markdown'
- def _raw_formats_default(self):
- return ['md', 'markdown', 'html']
+ def _raw_mimetypes_default(self):
+ 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 0eed525..1d13bc3 100644
--- a/IPython/nbconvert/exporters/python.py
+++ b/IPython/nbconvert/exporters/python.py
@@ -29,9 +29,6 @@ class PythonExporter(TemplateExporter):
'py', config=True,
help="Extension of the file that should be written to disk")
- def _raw_format_default(self):
- return 'python'
-
- def _raw_formats_default(self):
- return ['py', 'python']
+ def _raw_mimetype_default(self):
+ return 'application/x-python'
diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py
index c308ba7..22dfc82 100644
--- a/IPython/nbconvert/exporters/rst.py
+++ b/IPython/nbconvert/exporters/rst.py
@@ -30,12 +30,9 @@ class RSTExporter(TemplateExporter):
'rst', config=True,
help="Extension of the file that should be written to disk")
- def _raw_format_default(self):
- return 'rst'
+ def _raw_mimetype_default(self):
+ return 'text/restructuredtext'
- def _raw_formats_default(self):
- return ['rst', 'restructuredtext']
-
@property
def default_config(self):
c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
diff --git a/IPython/nbconvert/exporters/templateexporter.py b/IPython/nbconvert/exporters/templateexporter.py
index f79471e..a5eed82 100644
--- a/IPython/nbconvert/exporters/templateexporter.py
+++ b/IPython/nbconvert/exporters/templateexporter.py
@@ -126,12 +126,12 @@ class TemplateExporter(Exporter):
help="""Dictionary of filters, by name and namespace, to add to the Jinja
environment.""")
- raw_format = Unicode('')
- raw_formats = List(config=True,
+ raw_mimetype = Unicode('')
+ raw_mimetypes = List(config=True,
help="""formats of raw cells to be included in this Exporter's output."""
)
- def _raw_formats_default(self):
- return [self.raw_format]
+ def _raw_mimetypes_default(self):
+ return [self.raw_mimetype]
def __init__(self, config=None, extra_loaders=None, **kw):
@@ -209,8 +209,8 @@ class TemplateExporter(Exporter):
preprocessors and filters.
"""
nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
- resources.setdefault('raw_format', self.raw_format)
- resources.setdefault('raw_formats', self.raw_formats)
+ 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 ee09ba4..9db1caa 100644
--- a/IPython/nbconvert/exporters/tests/base.py
+++ b/IPython/nbconvert/exporters/tests/base.py
@@ -22,7 +22,13 @@ from ...tests.base import TestsBase
# Class
#-----------------------------------------------------------------------------
-all_raw_formats = set(['markdown', 'html', 'rst', 'python', 'latex'])
+all_raw_mimetypes = {
+ 'application/x-python',
+ 'text/markdown',
+ 'text/html',
+ 'text/restructuredtext',
+ 'text/latex',
+}
class ExportersTestsBase(TestsBase):
"""Contains base test functions for exporters"""
@@ -35,14 +41,14 @@ class ExportersTestsBase(TestsBase):
@onlyif_cmds_exist('pandoc')
def test_raw_cell_inclusion(self):
- """test raw cell inclusion based on raw_format metadata"""
+ """test raw cell inclusion based on raw_mimetype metadata"""
if self.should_include_raw is None:
return
exporter = self.exporter_class()
(output, resources) = exporter.from_filename(self._get_notebook('rawtest.ipynb'))
for inc in self.should_include_raw:
self.assertIn('raw %s' % inc, output, "should include %s" % inc)
- self.assertIn('no raw_format metadata', output)
- for exc in all_raw_formats.difference(self.should_include_raw):
+ self.assertIn('no raw_mimetype metadata', output)
+ for exc in all_raw_mimetypes.difference(self.should_include_raw):
self.assertNotIn('raw %s' % exc, output, "should exclude %s" % exc)
self.assertNotIn('never be included', output)
diff --git a/IPython/nbconvert/exporters/tests/files/rawtest.ipynb b/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
index c2a8b14..667ddbf 100644
--- a/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
+++ b/IPython/nbconvert/exporters/tests/files/rawtest.ipynb
@@ -10,7 +10,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_format": "html"
+ "raw_mimetype": "text/html"
},
"source": [
"raw html"
@@ -19,7 +19,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_format": "markdown"
+ "raw_mimetype": "text/markdown"
},
"source": [
"* raw markdown\n",
@@ -30,7 +30,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_format": "rst"
+ "raw_mimetype": "text/restructuredtext"
},
"source": [
"``raw rst``\n",
@@ -43,7 +43,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_format": "python"
+ "raw_mimetype": "application/x-python"
},
"source": [
"def bar():\n",
@@ -54,7 +54,7 @@
{
"cell_type": "raw",
"metadata": {
- "raw_format": "latex"
+ "raw_mimetype": "text/latex"
},
"source": [
"\\LaTeX\n",
@@ -65,13 +65,13 @@
"cell_type": "raw",
"metadata": {},
"source": [
- "# no raw_format metadata, should be included by default"
+ "# no raw_mimetype metadata, should be included by default"
]
},
{
"cell_type": "raw",
"metadata": {
- "raw_format": "doesnotexist"
+ "raw_mimetype": "doesnotexist"
},
"source": [
"garbage format defined, should never be included"
diff --git a/IPython/nbconvert/templates/latex/skeleton/null.tplx b/IPython/nbconvert/templates/latex/skeleton/null.tplx
index 7fa6b48..5f8909b 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_format', resources.get('raw_format')) == resources.get('raw_format') *))
+ ((* if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype')) == resources.get('raw_mimetype') *))
((( cell.source )))
((* endif *))
((*- endblock rawcell -*))
diff --git a/IPython/nbconvert/templates/skeleton/null.tpl b/IPython/nbconvert/templates/skeleton/null.tpl
index 2d40ed3..aec85f4 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_format', resources.get('raw_format', '')).lower() in resources.get('raw_formats', ['']) %}
+ {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
{{ cell.source }}
{% endif %}
{%- endblock rawcell -%}