From 434f472251150cbdc0a9a15e41dff2e022bcf111 Mon Sep 17 00:00:00 2001 From: Pio Mendoza <69317890+peeeyow@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:21:38 +0800 Subject: [PATCH] feat(backlinks): make relative to root links searchable --- CHANGELOG.md | 4 ++++ lua/obsidian/client.lua | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38752b8ea..3aaad6e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added relative to root markdown links as search pattern for backlinks. + ## [v3.7.14](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.14) - 2024-06-04 ### Added diff --git a/lua/obsidian/client.lua b/lua/obsidian/client.lua index 325d40bed..372660dbe 100644 --- a/lua/obsidian/client.lua +++ b/lua/obsidian/client.lua @@ -1297,10 +1297,14 @@ Client.find_backlinks_async = function(self, note, callback, opts) search_terms[#search_terms + 1] = string.format("[[%s|", ref) -- Markdown link without anchor/block. search_terms[#search_terms + 1] = string.format("(%s)", ref) + -- Markdown link without anchor/block and is relative to root. + search_terms[#search_terms + 1] = string.format("(/%s)", ref) -- Wiki links with anchor/block. search_terms[#search_terms + 1] = string.format("[[%s#", ref) -- Markdown link with anchor/block. search_terms[#search_terms + 1] = string.format("(%s#", ref) + -- Markdown link with anchor/block and is relative to root. + search_terms[#search_terms + 1] = string.format("(/%s#", ref) elseif anchor then -- Note: Obsidian allow a lot of different forms of anchor links, so we can't assume -- it's the standardized form here. @@ -1308,11 +1312,15 @@ Client.find_backlinks_async = function(self, note, callback, opts) search_terms[#search_terms + 1] = string.format("[[%s#", ref) -- Markdown link with anchor. search_terms[#search_terms + 1] = string.format("(%s#", ref) + -- Markdown link with anchor and is relative to root. + search_terms[#search_terms + 1] = string.format("(/%s#", ref) elseif block then -- Wiki links with block. search_terms[#search_terms + 1] = string.format("[[%s#%s", ref, block) -- Markdown link with block. search_terms[#search_terms + 1] = string.format("(%s#%s", ref, block) + -- Markdown link with block and is relative to root. + search_terms[#search_terms + 1] = string.format("(/%s#%s", ref, block) end end end