Skip to content

Commit

Permalink
Merge pull request #191 from MODUSCarstenScholling/dev-164-alerts
Browse files Browse the repository at this point in the history
#164 Allow common [!ANY] alerts
  • Loading branch information
mjbvz authored Oct 29, 2024
2 parents 955d899 + 73ad4d5 commit 9d31cad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/languageFeatures/documentLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ const referenceLinkPattern = new RegExp(

/**/r`|` +

// [shorthand]
/****/r`\[\s*(?<shorthand>(?:\\.|[^\[\]\\])+?)\s*\]` +
// [shorthand] but not [!shorthand]
/****/r`\[(?!\!)\s*(?<shorthand>(?:\\.|[^\[\]\\])+?)\s*\]` +
r`)` +
r`(?![\(])`, // Must not be followed by a paren to avoid matching normal links
'gm');
Expand Down Expand Up @@ -816,4 +816,3 @@ export function createWorkspaceLinkCache(
const linkComputer = new MdLinkComputer(parser, workspace);
return new MdWorkspaceInfoCache(workspace, (doc, token) => linkComputer.getAllLinks(doc, token));
}

8 changes: 8 additions & 0 deletions src/test/documentLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ suite('Link computer', () => {
]);
});

test('Should not find reference link shorthand when prefixed with ! (#164)', async () => {
const links = await getLinksForText(joinLines(
'[!note]',
'[!anything]',
));
assertLinksEqual(links, []);
});

test('Should find reference link with space in reference name', async () => {
const links = await getLinksForText(joinLines(
'[text][my ref]',
Expand Down

0 comments on commit 9d31cad

Please sign in to comment.