diff --git a/packages/docusaurus-utils/src/__tests__/__snapshots__/markdownLinks.test.ts.snap b/packages/docusaurus-utils/src/__tests__/__snapshots__/markdownLinks.test.ts.snap index 7c5fc874287c..3c4f732a82fd 100644 --- a/packages/docusaurus-utils/src/__tests__/__snapshots__/markdownLinks.test.ts.snap +++ b/packages/docusaurus-utils/src/__tests__/__snapshots__/markdownLinks.test.ts.snap @@ -176,6 +176,7 @@ exports[`replaceMarkdownLinks replaces links with same title as URL 1`] = ` "brokenMarkdownLinks": [], "newContent": " [foo.md](/docs/foo) +[./foo.md]() [./foo.md](/docs/foo) [foo.md](/docs/foo) [./foo.md](/docs/foo) diff --git a/packages/docusaurus-utils/src/__tests__/markdownLinks.test.ts b/packages/docusaurus-utils/src/__tests__/markdownLinks.test.ts index b7d7abd556b5..ce0acfb3a99b 100644 --- a/packages/docusaurus-utils/src/__tests__/markdownLinks.test.ts +++ b/packages/docusaurus-utils/src/__tests__/markdownLinks.test.ts @@ -231,6 +231,7 @@ The following operations are defined for [URI]s: }, fileString: ` [foo.md](foo.md) +[./foo.md](<./foo.md>) [./foo.md](./foo.md) [foo.md](./foo.md) [./foo.md](foo.md) diff --git a/packages/docusaurus-utils/src/markdownLinks.ts b/packages/docusaurus-utils/src/markdownLinks.ts index 88825e502f14..13afca33905e 100644 --- a/packages/docusaurus-utils/src/markdownLinks.ts +++ b/packages/docusaurus-utils/src/markdownLinks.ts @@ -128,7 +128,7 @@ export function replaceMarkdownLinks({ const linkSuffixPattern = '(?:\\?[^#>\\s]+)?(?:#[^>\\s]+)?'; const linkCapture = (forbidden: string) => `((?!https?://|@site/)[^${forbidden}#?]+)`; - const linkURLPattern = `(?:${linkCapture( + const linkURLPattern = `(?:(?!<)${linkCapture( '()\\s', )}${linkSuffixPattern}|<${linkCapture('>')}${linkSuffixPattern}>)`; const linkPattern = new RegExp(