Skip to content

Commit

Permalink
feat(backlinks): make relative to root links searchable
Browse files Browse the repository at this point in the history
  • Loading branch information
peeeyow committed Jun 16, 2024
1 parent c6bd6d9 commit 2271daf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/obsidian/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1297,22 +1297,30 @@ 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.
-- Wiki links with anchor.
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
Expand Down

0 comments on commit 2271daf

Please sign in to comment.