From 9ee9c8e1de56756511c9c76fb96fb2fbcb7db117 2013-11-14 01:14:25 From: Peter Davis Date: 2013-11-14 01:14:25 Subject: [PATCH] Add strip_url_static_file_prefix to filters --- diff --git a/IPython/nbconvert/filters/latex.py b/IPython/nbconvert/filters/latex.py index f366702..ac35277 100755 --- a/IPython/nbconvert/filters/latex.py +++ b/IPython/nbconvert/filters/latex.py @@ -19,6 +19,8 @@ import re # Globals and constants #----------------------------------------------------------------------------- +MARKDOWN_IMAGE_RE = re.compile(r'!\[(?P.*?)\]\(/?files/(?P.*?)\)') + LATEX_RE_SUBS = ( (re.compile(r'\.\.\.+'), r'\\ldots'), ) @@ -44,7 +46,8 @@ LATEX_SUBS = { # Functions #----------------------------------------------------------------------------- -__all__ = ['escape_latex'] +__all__ = ['escape_latex', + 'strip_url_static_file_prefix'] def escape_latex(text): """ @@ -61,3 +64,9 @@ def escape_latex(text): return text + +def strip_url_static_file_prefix(text): + text = MARKDOWN_IMAGE_RE.sub(r'![\1](\2)', text) + return text + +