Module:Author link

--[=[ Helper functons to construct author links ]=]

local p = {} --p stands for package

-- construct an author link from a given string function p.constructAuthorLink(str) -- strip "Portal:" prefixes if not piped str = string.gsub(str, "%[%[%s*Portal:([^|]-)|?%]%]", function (target)		return "" .. target .. ""	end) -- And for authors str = string.gsub(str, "%[%[%s*Author:([^|]-)|?%]%]", function (target)		return "" .. target .. ""	end) -- auto-strip bracketed dates str = string.gsub(str, "^((.*) +%([0-9]+[-–][0-9]+%))$", function (full_target, no_date)		return "" .. no_date .. ""	end, 1)

-- if the string has its own links, return it now if string.match(str, "%[%[") then return str end

if string.match(str, "[uU]nknown") then return "Anonymous" end if string.match(str, "[vV]arious") then return "Various" end -- if a pipe is provided if string.match(str, "|") then return "Author:" .. str .. "" end -- make our own piped link return "" .. str .. "" end

return p