Search code examples
markdownbitbucket

Link to filenames with spaces in Bitbucket Markdown


Let's say I have a README.md and I'd like to create a link to a file that contains spaces in its name, file with spaces.md. I'd like to be able to jump to the file's source code.

/
 -- README.md
 -- File with spaces.md

After inspecting the element in the browser, I figured out what the href should be (changed it manually, then clicking on it brought me to the page I want to reach):

<a href="username/repository/src/c0mm1th4sH/File%20with%20%spaces.md">

Unfortunately I couldn't accomplish that. Some of the things I have tried so far:

[Link](File with spaces.md)
[Link](File%20with%20spaces.md)
[Link](File\ with\ spaces.md)
[Link]("File with spaces.md")

It results in the following HTML in Bitbucket:

<a href="/username/repository/src/c0mm1th4sH/File%2520with%2520spaces.md">
<a href="/username/repository/src/c0mm1th4sH/File%2520with%2520spaces.md">
<a href="/username/repository/src/c0mm1th4sH/File%5C%2520with%5C%2520spaces.md">
<a href="" title="File with spaces.md">

You can play with the example repository I created.

Update: the bug is gone, so simple spaces or %20 will work now.


Solution

  • There was, in fact, a bug on Bitbucket's side, however, the bug is now fixed.

    Assuming your file is called File with spaces.md and the text you want to be displayed is Link, either of these two methods will work:

    * [Link](File with spaces.md)
    * [Link](File%20with%20spaces.md)