summaryrefslogtreecommitdiff
path: root/repo/www/convert-internal-links.lua
blob: b0817ddb2ec1577fdcc036d99f463f950c81b586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
EXTENSIONS = {}

string.gsub(
  os.getenv("TEXT_FILES"),
  "[^%s]+",
  function (ext) EXTENSIONS[#EXTENSIONS+1] = ext end
)

function Link(link)
  if link.target:match("^[%w]+://")
  then
    return link
  end

  for _, ext in pairs(EXTENSIONS)
  do
    link.target = link.target:gsub("%."..ext.."$", ".html")
  end

  return link
end