##// END OF EJS Templates
fix `file/` URL replacements in nbconvert
MinRK -
Show More
@@ -15,7 +15,7 b' templates.'
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 # Our own imports
18 import re
19 import textwrap
19 import textwrap
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
@@ -63,16 +63,19 b' def strip_dollars(text):'
63 return text.strip('$')
63 return text.strip('$')
64
64
65
65
66 files_url_pattern = re.compile(r'(src|href)\=([\'"]?)files/')
67
66 def rm_fake(text):
68 def rm_fake(text):
67 """
69 """
68 Remove all occurrences of 'files/' from text
70 Fix all fake URLs that start with `files/`,
71 stripping out the `files/` prefix.
69
72
70 Parameters
73 Parameters
71 ----------
74 ----------
72 text : str
75 text : str
73 Text to remove 'files/' from
76 Text in which to replace 'src="files/real...' with 'src="real...'
74 """
77 """
75 return text.replace('files/', '')
78 return files_url_pattern.sub(r"\1=\2", text)
76
79
77
80
78 def python_comment(text):
81 def python_comment(text):
General Comments 0
You need to be logged in to leave comments. Login now