Module:Links

-- Creates links and changes wikitext when it detects external links -- Syntax -- {{{{#invoke:links|main|page/url|label|type=ext|local}} local utility = require("Module:Utility") local p = { link = function(tArgs) local link,url,desc,separator ="","","","","" local sPrefix = ""   local sSuffix = "" if tArgs then url = tArgs[1] or tArgs['page'] or "" desc = tArgs[2] or tArgs['desc'] or "" if url:len<1 then return end if (desc:len>0) then separator = "|" end if url and url:len>2 then local isExternalUrl = url:match("www.") or url:match("^http") if (isExternalUrl and tArgs['type']~="local" or tArgs['type']=="ext" ) then sPrefix = "[//" sSuffix = "]" separator = " " end end link = sPrefix .. url .. separator..desc.. sSuffix end return link end } p.main = function(frame) local tArgs = utility.getArgs(frame) return p.link(tArgs) end return p