summaryrefslogtreecommitdiff
path: root/support/make4ht/filters/make4ht-fix-links.lua
blob: 4dbc26824f39e1db4ccb4b9ba994c74bd1f08004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- replace colons in `id` or `href` attributes for local links with underscores
--

local function fix_href_colons(s)
  return s:gsub('(href=".-")', function(a)
    if a:match("[a-z]%://") then return a end
    return a:gsub(":","_")
  end)
end

local function fix_id_colons(s)
  return s:gsub('(id=".-")', function(a)
    return a:gsub(":", "_")
  end)
end

return function(s)
  return fix_id_colons(fix_href_colons(s))
end