blob: 7ab72da09c3965666ed66858dc655e9756071dae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
function mark(name)
return ' <span class="icon"><svg><use href="/img/icons.svg#'
.. name ..
'"></use></svg></span>'
end
links = HTML.select(page, "a")
index, link = next(links)
while index do
href = HTML.get_attribute(link, "href")
todo = not HTML.get_attribute(link, "marked")
if href and todo then
if Regex.match(href, "^https?://github.com") then
icon = HTML.parse(mark("github"))
HTML.insert_after(link, icon)
elseif Regex.match(href, "^https?://") then
icon = HTML.parse(mark("external-link"))
HTML.insert_after(link, icon)
end
HTML.set_attribute(link, "marked", "")
end
index, link = next(links, index)
end
|