diff options
author | Thomas Letan <lthms@soap.coffee> | 2020-02-15 23:34:34 +0100 |
---|---|---|
committer | Thomas Letan <lthms@soap.coffee> | 2020-02-15 23:39:56 +0100 |
commit | 8852c973af08fe6f97c1be6e53524d1dcb2b0eea (patch) | |
tree | 6acb1dd32954f5102fd3acd2d3c0b1902e42f21f /plugins | |
parent | Add missing fonts and rename the plugin (diff) |
Mark external links with a dedicated icon
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/external_links.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/external_links.lua b/plugins/external_links.lua new file mode 100644 index 0000000..0edf9d8 --- /dev/null +++ b/plugins/external_links.lua @@ -0,0 +1,16 @@ +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?://") then + icon = HTML.parse("<i class=\"fa fa-external-link\" aria-hidden=\"true\"></i>") + HTML.append_child(link, icon) + end + end + + index, link = next(links, index) +end |