MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Explain that markdown internal links to documents cannot contain spaces

Open choldgraf opened this issue 3 years ago • 4 comments

Describe the bug

context When somebody references a local document that has a space in the title, the reference does not properly resolve. So for example, [my text](./path/to/my doc.md will not resolve properly, but [my text](./path/to/my_doc.md) will be fine.

Reproduce the bug

  • Create a sibling page called test file.md next to a pre-existing docs page. Give a title like # test

  • In a pre-existing sibling page, paste this markdown:

    - [](test file.md)
    - [](test file)
    - {doc}`test file`
    

The first two links will not work, the third does. Here's how it looks on my screen:

image

List your environment

the above example was run via tox -e docs-live on master.

Resolution

I think we could resolve this either:

  • By patching the code so that we know how to handle filename spaces
  • By documenting that if somebody wants a space in their filename, they must directly use the {doc} role

ref: https://github.com/executablebooks/meta/discussions/654 where this was first reported

choldgraf avatar Feb 10 '22 20:02 choldgraf

It's not valid common mark so there is no way to support it, unless you can find a way in http://markdown-it.github.io/

chrisjsewell avatar Feb 10 '22 21:02 chrisjsewell

In that case, I think that we should just document it so that users know what to expect. I'll re-tag this as a docs improvement.

choldgraf avatar Feb 10 '22 23:02 choldgraf

Cheers, it's unfortunate, but not much I can go in this matter, unless there is a common mark compliant solution I'm missing

chrisjsewell avatar Feb 10 '22 23:02 chrisjsewell

Is a slash escaped space or space separated tokens "wrapped in quotes" also not handled?

psychemedia avatar Apr 07 '22 19:04 psychemedia

Closing as now explained in https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#commonmark-link-format

i.e. you just need to wrap in <> like [](<test file.md>)

chrisjsewell avatar Feb 10 '23 01:02 chrisjsewell