Jump to content
Wikipedia The Free Encyclopedia

Module:Redirect-distinguish

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module depends on the following other modules:

Implements {{redirect-distinguish }}.

See also

The above documentation is transcluded from Module:Redirect-distinguish/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

 localmHatnote=require('Module:Hatnote')
 localmHatlist=require('Module:Hatnote list')
 localmArguments--initialize lazily
 localmTableTools=require('Module:TableTools')
 localp={}

 functionp.redirectDistinguish(frame)
 mArguments=require('Module:Arguments')
 localargs=mArguments.getArgs(frame)
 returnp._redirectDistinguish(args)
 end

 functionp._redirectDistinguish(args)
 ifnotargs[1]then
 returnmHatnote.makeWikitextError(
 'no redirect supplied',
 'Template:Redirect-distinguish',
 args.category
 )
 end
 localredirectTitle=mw.title.new(args[1])
 localcurrentTitle=currentTitleormw.title.getCurrentTitle()
 if
 string.match(args[1],'REDIRECT%d+')or
 args[1]=='TERM'or
 currentTitle.namespace~=0
 then
 --do nothing
 elseifnotredirectTitleornotredirectTitle.existsthen
 args[1]=args[1]..'[[Category:Missing redirects]]'
 elseifnotredirectTitle.isRedirectthen
 ifstring.find(redirectTitle:getContent(),'#invoke:RfD')then
 args[1]=args[1]..
 '[[Category:Articles with redirect hatnotes impacted by RfD]]'
 else
 args[1]=args[1]..
 '[[Category:Articles with redirect hatnotes needing review]]'
 end
 end
 ifnotargs[2]then
 returnmHatnote.makeWikitextError(
 'no page to be distinguished supplied',
 'Template:Redirect-distinguish',
 args.category
 )
 end
 args=mTableTools.compressSparseArray(args)
 --Assignment by removal here makes for convenient concatenation later
 localredirect=table.remove(args,1)
 localtext=string.format(
 '"%s" redirects here; not to be confused with %s.',
 redirect,
 mHatlist.orList(args,true)
 )
 returnmHatnote._hatnote(text)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /