mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
docs/fix-links: handle #anchor
targets on the same page
This commit is contained in:
parent
7f29e4b2ae
commit
a39e0a6516
1 changed files with 7 additions and 3 deletions
|
@ -18,9 +18,13 @@ function Link(link)
|
|||
local target = link.target
|
||||
-- Check for relative links
|
||||
-- TODO: handle ../
|
||||
if hasPrefix("./", target) then
|
||||
link.target = githubUrl .. sub(target, 3)
|
||||
return link
|
||||
while hasPrefix("./", target) do
|
||||
-- strip leading ./
|
||||
target = sub(target, 3)
|
||||
end
|
||||
if hasPrefix("#", target) then
|
||||
-- No-op for anchor targets on the same page
|
||||
return nil
|
||||
end
|
||||
if not hasPrefix("https://", target) then
|
||||
link.target = githubUrl .. target
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue