diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py index e84b6fe..b9ba3e6 100755 --- a/IPython/nbconvert/exporters/exporter.py +++ b/IPython/nbconvert/exporters/exporter.py @@ -68,7 +68,8 @@ default_filters = { 'strip_math_space': filters.strip_math_space, 'wrap_text': filters.wrap_text, 'escape_latex': filters.escape_latex, - 'citation2latex': filters.citation2latex + 'citation2latex': filters.citation2latex, + 'path2url': filters.path2url, } #----------------------------------------------------------------------------- diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py index 160fd67..5bce932 100644 --- a/IPython/nbconvert/exporters/markdown.py +++ b/IPython/nbconvert/exporters/markdown.py @@ -13,6 +13,7 @@ Exporter that will export your ipynb to Markdown. # Imports #----------------------------------------------------------------------------- +from IPython.config import Config from IPython.utils.traitlets import Unicode from .exporter import Exporter @@ -29,3 +30,9 @@ class MarkdownExporter(Exporter): file_extension = Unicode( 'md', config=True, help="Extension of the file that should be written to disk") + + @property + def default_config(self): + c = Config({'ExtractOutputPreprocessor':{'enabled':True}}) + c.merge(super(MarkdownExporter,self).default_config) + return c diff --git a/IPython/nbconvert/filters/strings.py b/IPython/nbconvert/filters/strings.py index 36d8b4b..be647bb 100755 --- a/IPython/nbconvert/filters/strings.py +++ b/IPython/nbconvert/filters/strings.py @@ -19,6 +19,7 @@ templates. import os import re import textwrap +from urllib2 import quote from xml.etree import ElementTree from IPython.core.interactiveshell import InteractiveShell @@ -38,6 +39,7 @@ __all__ = [ 'get_lines', 'ipython2python', 'posix_path', + 'path2url', ] @@ -181,3 +183,8 @@ def posix_path(path): if os.path.sep != '/': return path.replace(os.path.sep, '/') return path + +def path2url(path): + """Turn a file path into a URL""" + parts = path.split(os.path.sep) + return '/'.join(quote(part) for part in parts) diff --git a/IPython/nbconvert/templates/markdown.tpl b/IPython/nbconvert/templates/markdown.tpl index 20791b0..399c012 100644 --- a/IPython/nbconvert/templates/markdown.tpl +++ b/IPython/nbconvert/templates/markdown.tpl @@ -31,15 +31,15 @@ {% endblock stream %} {% block data_svg %} -[!image]({{ output.svg_filename }}) +![svg]({{ output.svg_filename | path2url }}) {% endblock data_svg %} {% block data_png %} -[!image]({{ output.png_filename }}) +![png]({{ output.png_filename | path2url }}) {% endblock data_png %} {% block data_jpg %} -[!image]({{ output.jpg_filename }}) +![jpeg]({{ output.jpeg_filename | path2url }}) {% endblock data_jpg %} {% block data_latex %}