Don't detect links in markdown code blocks (#149680)

Fixes #149678
This commit is contained in:
Matt Bierner
2022-05-16 17:35:16 -07:00
committed by GitHub
parent d71f6ec0d9
commit c2b064538b
2 changed files with 88 additions and 42 deletions

View File

@@ -270,4 +270,47 @@ suite('markdown.DocumentLinkProvider', () => {
const link = links[0];
assertRangeEqual(link.range, new vscode.Range(0, 5, 0, 23));
});
test('Should not detect links inside html comment blocks', async () => {
const links = await getLinksForFile(joinLines(
`<!-- <http://example.com> -->`,
`<!-- [text](./foo.md) -->`,
`<!-- [text]: ./foo.md -->`,
``,
`<!--`,
`<http://example.com>`,
`-->`,
``,
`<!--`,
`[text](./foo.md)`,
`-->`,
``,
`<!--`,
`[text]: ./foo.md`,
`-->`,
));
assert.strictEqual(links.length, 0);
});
test.skip('Should not detect links inside inline html comments', async () => {
// See #149678
const links = await getLinksForFile(joinLines(
`text <!-- <http://example.com> --> text`,
`text <!-- [text](./foo.md) --> text`,
`text <!-- [text]: ./foo.md --> text`,
``,
`text <!--`,
`<http://example.com>`,
`--> text`,
``,
`text <!--`,
`[text](./foo.md)`,
`--> text`,
``,
`text <!--`,
`[text]: ./foo.md`,
`--> text`,
));
assert.strictEqual(links.length, 0);
});
});