xrefcheck icon indicating copy to clipboard operation
xrefcheck copied to clipboard

[BUG] Spaces in local links

Open dcastro opened this issue 2 years ago • 1 comments

Description

Say we have a file named a b.md.

The naive attempt to link to this file would be to use [link](a b.md), but the commonmark spec says that's not a valid link, see example 487. That will just be rendered as a plain text literal, not as a link.

The spec clarifies:

The destination can only contain spaces if it is enclosed in pointy brackets:

Which means there are two correct ways to refer to this file:

  1. By using pointy brackets: [link](<a b.md>)
  2. By percent-encoding the space: [link](a%20.md)

Xrefcheck says (1) is indeed valid, but it reports (2) as a broken link (which it isn't).

To Reproduce

Steps to reproduce the behavior:

$ touch 'a b.md'
$ echo "[link](a%20b.md)" > test.md
$ xrefcheck --include-untracked

Configuration file not found, using default config for GitHub repositories

=== Invalid references found ===                                                                                                                    

  ➥  In file test.md
     bad reference (relative) at src:1:1-16:
       - text: "link"
       - link: a%20b.md
       - anchor: -

     File does not exist:
       a%20b.md

Invalid references dumped, 1 in total.

Expected behavior

Expected the steps above to succeed without errors

Environment

  • d1f465048eb2d9f345dbcfcc645a07440c7ebe80

dcastro avatar Mar 24 '23 10:03 dcastro

:pogchamp: Interesting spot!

Martoon-00 avatar Mar 24 '23 11:03 Martoon-00