diff --git a/extensions/markdown-language-features/src/features/documentLinkProvider.ts b/extensions/markdown-language-features/src/features/documentLinkProvider.ts index e4015e69a7626..e2bd61b2e9dc5 100644 --- a/extensions/markdown-language-features/src/features/documentLinkProvider.ts +++ b/extensions/markdown-language-features/src/features/documentLinkProvider.ts @@ -15,7 +15,9 @@ function parseLink( document: vscode.TextDocument, link: string, ): { uri: vscode.Uri, tooltip?: string } | undefined { - const externalSchemeUri = getUriForLinkWithKnownExternalScheme(link); + + const cleanLink = stripAngleBrackets(link); + const externalSchemeUri = getUriForLinkWithKnownExternalScheme(cleanLink); if (externalSchemeUri) { // Normalize VS Code links to target currently running version if (isOfScheme(Schemes.vscode, link) || isOfScheme(Schemes['vscode-insiders'], link)) { @@ -89,6 +91,15 @@ function extractDocumentLink( } } +/* Used to strip brackets from the markdown link + will be transformed to + http://example.com +*/ +export function stripAngleBrackets(link: string) { + const bracketMatcher = /^<(.*)>$/; + return link.replace(bracketMatcher, '$1'); +} + export default class LinkProvider implements vscode.DocumentLinkProvider { private readonly linkPattern = /(\[((!\[[^\]]*?\]\(\s*)([^\s\(\)]+?)\s*\)\]|(?:\\\]|[^\]])*\])\(\s*)(([^\s\(\)]|\([^\s\(\)]*?\))+)\s*(".*?")?\)/g; private readonly referenceLinkPattern = /(\[((?:\\\]|[^\]])+)\]\[\s*?)([^\s\]]*?)\]/g;