Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/documentLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ suite('Link computer', () => {
assertLinksEqual(links, []);
});

test.skip('Should not detect links inside inline html comments', async () => {
// See #149678
test('Should not detect links inside inline html comments', async () => {
// See microsoft/vscode-markdown-languageservice#52
const links = await getLinksForText(joinLines(
`text <!-- <http://example.com> --> text`,
`text <!-- [text](./foo.md) --> text`,
Expand Down
6 changes: 6 additions & 0 deletions src/util/noLinkRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { rangeContains } from '../types/range.js';
import { ITextDocument } from '../types/textDocument.js';

const inlineCodePattern = /(?<!`)(`+)((?:.+?|.*?(?:(?:\r?\n).+?)*?)(?:\r?\n)?\1)(?!`)/gm;
const htmlCommentPattern = /<!--[\s\S]*?-->/g;

class InlineRanges {

Expand Down Expand Up @@ -60,6 +61,11 @@ export class NoLinkRanges {
const startPosition = document.positionAt(startOffset);
inlineRanges.add(lsp.Range.create(startPosition, document.positionAt(startOffset + match[0].length)));
}
for (const match of text.matchAll(htmlCommentPattern)) {
const startOffset = match.index ?? 0;
const startPosition = document.positionAt(startOffset);
inlineRanges.add(lsp.Range.create(startPosition, document.positionAt(startOffset + match[0].length)));
}

return new NoLinkRanges(multiline, inlineRanges);
}
Expand Down