mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Properly handle links with title
This commit is contained in:
@@ -47,7 +47,7 @@ function matchAll(
|
||||
}
|
||||
|
||||
export default class LinkProvider implements vscode.DocumentLinkProvider {
|
||||
private readonly linkPattern = /(\[[^\]]*\]\(\s*)((([^\s\(\)]|\(\S*?\))+))\)/g;
|
||||
private readonly linkPattern = /(\[[^\]]*\]\(\s*)((([^\s\(\)]|\(\S*?\))+))\s*(".*?")?\)/g;
|
||||
private readonly referenceLinkPattern = /(\[([^\]]+)\]\[\s*?)([^\s\]]*?)\]/g;
|
||||
private readonly definitionPattern = /^([\t ]*\[([^\]]+)\]:\s*)(\S+)/gm;
|
||||
|
||||
|
||||
@@ -65,6 +65,14 @@ suite('markdown.DocumentLinkProvider', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Should detect links with title', () => {
|
||||
const links = getLinksForFile('a [b](https://example.com "abc") c');
|
||||
assert.strictEqual(links.length, 1);
|
||||
const [link] = links;
|
||||
assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 25));
|
||||
});
|
||||
|
||||
|
||||
test('Should handle links with balanced parens', () => {
|
||||
{
|
||||
const links = getLinksForFile('a [b](https://example.com/a()c) c');
|
||||
|
||||
Reference in New Issue
Block a user