Skip to content

Commit

Permalink
docs/fix-links: handle #anchor targets on the same page
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Feb 14, 2025
1 parent 7f29e4b commit a39e0a6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/fix-links/filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a39e0a6

Please sign in to comment.