mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +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
|
local target = link.target
|
||||||
-- Check for relative links
|
-- Check for relative links
|
||||||
-- TODO: handle ../
|
-- TODO: handle ../
|
||||||
if hasPrefix("./", target) then
|
while hasPrefix("./", target) do
|
||||||
link.target = githubUrl .. sub(target, 3)
|
-- strip leading ./
|
||||||
return link
|
target = sub(target, 3)
|
||||||
|
end
|
||||||
|
if hasPrefix("#", target) then
|
||||||
|
-- No-op for anchor targets on the same page
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
if not hasPrefix("https://", target) then
|
if not hasPrefix("https://", target) then
|
||||||
link.target = githubUrl .. target
|
link.target = githubUrl .. target
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue