From fe436d50da8e37612b0188be1b9f306043a9491e Mon Sep 17 00:00:00 2001 From: Kelly Stewart Date: Sat, 10 Aug 2024 09:57:56 +1000 Subject: [PATCH] fix: Fix stringifier incorrectly matching some links (#435) The previous regex would match the following: ``` abilityMods: [4, 2, 3, -3, 1, -1] resistances: "[Some Link](note.md)" ``` So that that the first group (the link text) would match: ``` 4, 2, 3, -3, 1, -1]\n resistances: "[Some Link ``` and the second group (the path) would match: ``` note.md ``` This commit changes the regex so that it doesn't falsely match in these cases and instead just matches the actual markdown link. --- src/parser/stringifier.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser/stringifier.ts b/src/parser/stringifier.ts index 31d1e3d..e614a04 100644 --- a/src/parser/stringifier.ts +++ b/src/parser/stringifier.ts @@ -32,11 +32,11 @@ export class LinkStringifier { */ static transformSource(source: string) { return source - .replace(/\[\[([\s\S]+?)\]\]/g, (_, $1) => + .replace(/\[\[([^]]+?)\]\]/g, (_, $1) => LinkStringifier.replaceWikiLink($1) ) .replace( - /\[([\s\S]*?)\]\(([\s\S]+?)\)/g, + /\[([^]]*?)\]\(([^)]+?)\)/g, (_, alias: string, path: string) => LinkStringifier.replaceMarkdownLink(path, alias) );