![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
This module detects if a given page is a disambiguation page.
Usage
{{#invoke:Disambiguation|isDisambiguationPage|Page title}}
- returns
yes
if the page is a disambiguation page, or nothing if the page is not a disambiguation page
Examples:
{{#invoke:Disambiguation|isDisambiguationPage|Paris}}
→{{#invoke:Disambiguation|isDisambiguationPage|New}}
→ yes{{#invoke:Disambiguation|isDisambiguationPage|Black swan (disambiguation)}}
→ yes
You can also use magic words like {{SUBJECTPAGENAME}}:
{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}}
→ yes
Usage within Lua modules
Import this module, e.g with
local mDisambiguation = require('Module:Disambiguation')
Then you can use the functions isDisambiguation
and _isDisambiguationPage
.
If you have already have a Title object for the page to check, get the content using the title object's getContent() method, and pass that into isDisambiguation
:
local isDab = mDisambiguation.isDisambiguation(content) -- returns true or false
- (where
content
is a string, the wikitext content of page to check)
If you don't otherwise need the title, you can pass in the page name to _isDisambiguationPage
:
local isDab = mDisambiguation._isDisambiguationPage(pageName) -- returns true or false
- (where
pageName
is a string, the name of page to check)
Internal operations
- Although set index articles are treated by some templates as disambiguation pages, they are actually considered a special type of list and are not treated as disambiguation pages by this module
- As this module relies on detecting templates with names like "disambiguation" in the article text, it is subject to false positives by templates such as {{italic disambiguation}}. These templates should be added to the falsePositives list in the code to exclude them.
- The list of disambiguation templates is maintained at Module:Disambiguation/templates.
local p = {}local mRedirect = require('Module:Redirect')local disambiguationTemplates = mw.loadData('Module:Disambiguation/templates')local function capitalize(s)-- This function only works on ASCII strings. If your wiki has-- disambiguation templates that use Unicode strings, use the commented-out-- line instead. Enwiki uses ASCII string manipulation only here to improve-- performance.return s:sub(1, 1):upper() .. s:sub(2, -1)-- return mw.ustring.upper(mw.ustring.sub(1, 1)) .. mw.ustring.sub(2, -1)endlocal function isDisambiguationTemplate(template)return disambiguationTemplates[capitalize(template)] or falseendp.isDisambiguation = function(content)-- false if there is no contentif content == nil thenreturn falseend-- redirects are not disambiguation pagesif mRedirect.getTargetFromText(content) ~= nil thenreturn falseend-- check for disambiguation templates in the contentlocal templateNames = {}for template in string.gmatch(content, "{{%s*([^|}]-)%s*[|}]") doif isDisambiguationTemplate(template) thenreturn trueendend-- check for magic wordif string.find(content, "__DISAMBIG__", 1, true) ~= nil thenreturn trueendreturn falseendp._isDisambiguationPage = function(page)-- Look "(disambiguation)" in the titleif string.find(page, "(disambiguation)",0,true) ~= nil thenreturn true;end-- Look for disamiguation template in page contentlocal title = mw.title.new(page)if not title then return false endlocal content = title:getContent()return p.isDisambiguation(content)end-- Entry points for templatesp.isDisambiguationPage = function(frame)local title = frame.args[1]return p._isDisambiguationPage(title) and "yes" or ""endreturn p
🔥 Top keywords: Main PageSpecial:SearchPage 3Wikipedia:Featured picturesHouse of the DragonUEFA Euro 2024Bryson DeChambeauJuneteenthInside Out 2Eid al-AdhaCleopatraDeaths in 2024Merrily We Roll Along (musical)Jonathan GroffJude Bellingham.xxx77th Tony AwardsBridgertonGary PlauchéKylian MbappéDaniel RadcliffeUEFA European Championship2024 ICC Men's T20 World CupUnit 731The Boys (TV series)Rory McIlroyN'Golo KantéUEFA Euro 2020YouTubeRomelu LukakuOpinion polling for the 2024 United Kingdom general electionThe Boys season 4Romania national football teamNicola CoughlanStereophonic (play)Gene WilderErin DarkeAntoine GriezmannProject 2025