Skip to content

Commit

Permalink
fix: Fix stringifier incorrectly matching some links (#435)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miscoined authored Aug 9, 2024
1 parent 5967a2f commit fe436d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parser/stringifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down

0 comments on commit fe436d5

Please sign in to comment.