From a057c815fd51c15a97aae8e25096b90e46d6ef8b Mon Sep 17 00:00:00 2001 From: Jakob von Gehlen Date: Sun, 3 May 2026 17:40:31 +0200 Subject: [PATCH] fix: resolve vault-root-relative wiki links correctly When niceLinks=true (default), [[category/name]] links were incorrectly resolved relative to the current file's subdirectory instead of from the vault root. Before: [[references/arxiv-2507.21678]] from /projects/infosse resolved to 'projects/references/arxiv-2507.21678' (wrong) After: [[references/arxiv-2507.21678]] from /projects/infosse resolves to 'references/arxiv-2507.21678' (correct) The fix adds a check: if the link already contains a path separator, treat it as vault-root-relative and use an empty base path. Bare filenames (no '/') continue to resolve from the current file's subdirectory, preserving existing behavior for same-folder links. --- perlite/.src/PerliteParsedown.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/perlite/.src/PerliteParsedown.php b/perlite/.src/PerliteParsedown.php index b6164e17..d29bfb2a 100644 --- a/perlite/.src/PerliteParsedown.php +++ b/perlite/.src/PerliteParsedown.php @@ -1295,18 +1295,18 @@ protected function inlineInternalLink($Excerpt) } - // use only the file name for nice links - if ($this->niceLinks == true) { - $segments = explode('/', $linkText); - $segments = array_slice($segments, count($segments) - 1, 1); - $linkText = $segments[0]; - } - + // Bug fix: vault-root-relative links (e.g. [[references/arxiv-2507.21678]]) + // should resolve from vault root, not from the current file's subdirectory. + // Only apply current-file-relative resolution for bare filenames (no '/'). + $linkHasPath = str_contains($linkFile, '/'); - if ($openNewTab == false) { + if ($openNewTab == false && !$linkHasPath) { $segments = explode('/', $path); $segments = array_slice($segments, 1, count($segments)); $path = implode('/', $segments); + } elseif ($linkHasPath) { + // Vault-root-relative: use empty path so link resolves from vault root + $path = ''; }