summaryrefslogtreecommitdiffstats
path: root/plugins/external_links.lua
blob: 2967364a53d13e366bce05ed6850d8f63fe93c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
links = HTML.select(page, "a")

index, link = next(links)

while index do
  href = HTML.get_attribute(link, "href")

  if href then
    if Regex.match(href, "^https?://github.com") then
      icon = HTML.parse("<i class=\"url-mark fa fa-github\" aria-hidden=\"true\"></i>")
      HTML.append_child(link, icon)
    elseif Regex.match(href, "^https?://") then
      icon = HTML.parse("<i class=\"url-mark fa fa-external-link\" aria-hidden=\"true\"></i>")
      HTML.append_child(link, icon)
    end
  end

  index, link = next(links, index)
end