Anonymous user
Module:Redirect: Difference between revisions
consistent parsing of passed page name, output when passed bracket, and interpretation of redirect
Enwikipedia>Darklama (rm extra space) |
Enwikipedia>Darklama (consistent parsing of passed page name, output when passed bracket, and interpretation of redirect) |
||
Line 9:
function p.main(frame)
local args, pargs = frame.args, (frame:getParent() or {}).args or {}
if not rname or not mw.ustring.match(rname, "%S") then return "" end
▲ local rname=args[1] or pargs[1] or ""
local rpage, err
if bracket then▼
-- avoid expensive operation when nothing to do
▲ local strip=mw.ustring.match(rname,"%[%[(.+)%]%]")
end▼
elseif rpage.id ==
▲ end
return
local redirect = mw.ustring.match( rpage:getContent() or "", "^#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*%[%[(.-)%]%]" )
return mw.ustring.format(bracket, redirect)
▲ end
▲ else return rname -- not a redirect so leave the original text (for some general-purpose template use)
▲ else err="File not found (id=0):"
return
▲ end
▲ else err="File not found (mw.title.new failed)"
▲ end
▲ return [=[<span style="text-color:red;">[[Module:redirect]] error: ]=] .. err .. [=[ - [[]=] .. rname .. [=[]]</span>]=]
end
|