Documentation for this module may be created at Module:HideLinks/doc
local p = {}
function p.HideWikiLinks(frame)
StartText=frame.args[1]
Color=frame.args[2] or "BLACK"
CurrentText = StartText
itsthere, _ = string.find(CurrentText, "%[%[.*%]%]")
while itsthere do --While there are wikilinks found, keep going.
_, _, short = string.find(CurrentText, "%[%[(.-)%]%]")
ispipe, _ = string.find(short, "|")
if ispipe then
_, _, shorterTarget = string.find(short, "(.-)|")
_, _, shorterText = string.find(short, "|(.*)")
else
shorterTarget = short
shorterText = short
end
ReplacementLink = "STARTBRACKETS" .. shorterTarget .. "|<span style='color: " .. Color .. ";'>" .. shorterText .. "</span>ENDBRACKETS"
CurrentText = string.gsub(CurrentText, "%[%[.-%]%]", ReplacementLink, 1)
itsthere, _ = string.find(CurrentText, "%[%[.*%]%]")
end --end of the while
--Now put the proper brackets back.
CurrentText = string.gsub(CurrentText, "STARTBRACKETS", "[[")
CurrentText = string.gsub(CurrentText, "ENDBRACKETS", "]]")
return CurrentText
end
return p