When converting file path URL if file path contains %20 change it to space

Consider following link
`[link](|filename|2007-08-22 exhausted.md)`

MarkdownReader converts it to `2007-08-22%20exhausted.md`.

When Pelican tries to convert file path url, it first checks whether the
file is present in specified directories or not.

It does not find `2007-08-22%20exhausted.md` because its name on file
system is `2007-08-22 exhausted.md`.

This fix replaces `%20` with space.

Closes  getpelican/pelican#1062
This commit is contained in:
Talha Mansoor 2013-09-26 01:19:42 +05:00
commit e6dab6b05f

View file

@ -217,6 +217,11 @@ class Content(object):
origin = '/'.join((siteurl, origin = '/'.join((siteurl,
self._context['filenames'][path].url)) self._context['filenames'][path].url))
origin = origin.replace('\\', '/') # for Windows paths. origin = origin.replace('\\', '/') # for Windows paths.
elif path.replace('%20', ' ') in self._context['filenames']:
path_with_spaces = path.replace('%20', ' ')
origin = '/'.join((siteurl,
self._context['filenames'][path_with_spaces].url))
origin = origin.replace('\\', '/') # for Windows paths.
else: else:
logger.warning("Unable to find {fn}, skipping url" logger.warning("Unable to find {fn}, skipping url"
" replacement".format(fn=path)) " replacement".format(fn=path))