Documentation for this module may be created at Module:Non-WLH link/doc
local linkUtil = require("Module:LinkUtil")
local textUtil = require('Module:TextUtil')
local varsUtil = require('Module:VarsUtil')
local p = {}
function p.nonWLHLink(link)
local linkText = mw.getCurrentFrame():preprocess("{{urlencode:" .. linkUtil.getLinkText(link) .. "|PATH}}")
local display = linkUtil.getLinkText(link)
if linkUtil.getDisplayText(link) and linkUtil.getDisplayText(link) ~= "" then
display = linkUtil.getDisplayText(link)
end
local ret = ""
if mw.getCurrentFrame():preprocess( "{{FULLPAGENAME}}" ) == linkUtil.getLinkText(link) then
ret = "'''" .. display .. "'''"
elseif not varsUtil.getVar("NWLH no red link check") or varsUtil.getVar("NWLH no red link check") == "" then
if mw.getCurrentFrame():expandTemplate{title = "Linkless exists", args = {linkUtil.getLinkText(link)}} == "" then
ret = "[[" .. linkUtil.getLinkText(link) .. "|" .. display .. "]]"
else
ret = "<span class=\"NWLH\" title=\"" .. linkUtil.getLinkText(link) .. "\">[//tardis.wiki/wiki/" .. linkText:gsub(' ', '_') .. " " .. display .. "]</span>"
end
else
ret = "<span class=\"NWLH\" title=\"" .. linkUtil.getLinkText(link) .. "\">[//tardis.wiki/wiki/" .. linkText:gsub(' ', '_') .. " " .. display .. "]</span>"
end
return ret
end
function p.nonWLHText(text)
for link in string.gmatch(text, "%[%[.-%]%]") do
text = text:gsub(textUtil.escape(link), textUtil.escape(p.nonWLHLink(link)))
end
return text
end
function p.nonWLHLinkWrapper(frame)
local link = frame:getParent().args[1]
return p.nonWLHLink(link)
end
function p.nonWLHTextWrapper(frame)
local text = frame:getParent().args[1]
return p.nonWLHText(text)
end
return p