Skip to content

Format markdown links containing space in filename [](<>) without greater and smaller sign and maintain URL encoding #235422

@netlimpopo

Description

@netlimpopo

Problem

VS Code adds <> to markdown links when the filename contains spaces, which causes issues with some parsers and static site builders.

Steps to reproduce

activate markdown: automatic link updates on file move.
Move file into a diffent folder. Then move it back to the original position. If the markdown file contains links that point to a filename with spaces, markdownlinks are changed to (<>).

Details

When file is moved, that contains a URL-encoded link to a filename containing spaces e.g.

[link](file%20with%20spaces.md)

VSCode adds <> to the resulting markdown link and removes the URLEncoded attributes. The result for example is [link](<file with spaces.md>).

However as a result VSCode has removed the url encoded property of the markdown link, causing issues in some static site generators or other markdown programmes as this is not a pure standard markdown format in links in general. <> are more common in www.webpages. Some parsers interpret [File]<file with spaces.md> as a website for instance.

Solution

It would be great if the links after file move get updated from [link](<file with spaces.md>) to [link](file%20with%20spaces.md). VSCode already has the power to provide url-encoded links.

Alternative I have considered

vs. Code

I use RegExp with: Find:

(?<=\]\([^\]\r\n]*)[^\S\r\n]+

Replace: %20 to find all spaces in Markdownlinks and replace it with %20.
Replace ](< with ]( and also >) with ).
I use Notepad ++ and a Macro to do the same:

(\G(?!\A)|\[[^][]*]\()([^()\s]*)\s
(\G(?!\A)|\[[^][]*]\()([^()\s]*)\s+(?=[^()]*\))

Replace $1$2%20. And also replace ](< with ]( and also >) with ).

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitymarkdown-extThe Markdown extension: language features and preview

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions