update pandoc filters

master
urosm 2024-08-03 15:57:46 +02:00
parent 0c9b6ee4c0
commit e913e6d236
1 changed files with 5 additions and 4 deletions

View File

@ -8,18 +8,19 @@ local visited = {}
return {
{ Link = function(link)
-- early return for visited
if visited[link.target] then return end
visited[link.target] = true
-- early return for external links
if link.target:find("^https?%:%/%/") then return end
if link.target:find("^mailto%:") then return end
local fp, anchor = link.target:match("^(.+%.md)#?(.*)$")
-- early return for non markdown files
if not fp then return end
-- early return for visited
if visited[fp] then return end
visited[fp] = true
local f = io.open(fp)
-- early return for broken internal links
if f == nil then return link.content else f:close() end -- @todo maybe log broken internal links