More actions
Created page with "{{Module rating|protected}} {{used in system}} {{lua|Module:Redirect}} This module detects if a given page is a disambiguation page. ==Usage== <pre> {{#invoke:Disambiguation|isDisambiguationPage|Page title}} </pre> :returns <code>yes</code> if the page is a disambiguation page, or nothing if the page is not a disambiguation page Examples: * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki>Paris}}</code> → {{#invoke:Disambiguation|isDisambiguat..." |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{wikipedia|page name}} | |||
{{Module rating|protected}} | {{Module rating|protected}} | ||
{{lua|Module:Redirect}} | {{lua|Module:Redirect}} | ||
This module detects if a given page is a disambiguation page. | This module detects if a given page is a disambiguation page. | ||
| Line 11: | Line 11: | ||
Examples: | Examples: | ||
* <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki> | * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki>Paris}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|Paris}} | ||
* <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki> | * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki>New}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|New}} | ||
* <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki> | * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki>Black swan (disambiguation)}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|Black swan (disambiguation)}} | ||
You can also use magic words like {{tl|SUBJECTPAGENAME}}: | You can also use magic words like {{tl|SUBJECTPAGENAME}}: | ||
* <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}</nowiki>}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}} | * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}</nowiki>}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}} | ||
| Line 24: | Line 24: | ||
Then you can use the functions <code>isDisambiguation</code> and <code>_isDisambiguationPage</code>. | Then you can use the functions <code>isDisambiguation</code> and <code>_isDisambiguationPage</code>. | ||
If you have already have a | 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 <code>isDisambiguation</code>: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local isDab = mDisambiguation.isDisambiguation(content) -- returns true or false | local isDab = mDisambiguation.isDisambiguation(content) -- returns true or false | ||
| Line 37: | Line 37: | ||
===Internal operations=== | ===Internal operations=== | ||
* Although | * 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 {{tl|italic disambiguation}}. These templates should be added to the falsePositives list in the code to exclude them. | * 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 {{tl|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 | * The list of disambiguation templates is maintained at Module:Disambiguation/templates. | ||
<includeonly>{{Sandbox other|| | <includeonly>{{Sandbox other|| | ||
Latest revision as of 18:15, 9 April 2025
| This page uses Creative Commons Licensed content from Wikipedia (view authors). |
| This module depends on the following other modules: |
This module detects if a given page is a disambiguation page.
Usage
{{#invoke:Disambiguation|isDisambiguationPage|Page title}}
- returns
yesif the page is a disambiguation page, or nothing if the page is not a disambiguation page
Examples:
{{#invoke:Disambiguation|isDisambiguationPage|Paris}}→ Lua error in package.lua at line 80: module 'Module:Disambiguation/templates' not found.{{#invoke:Disambiguation|isDisambiguationPage|New}}→ Lua error in package.lua at line 80: module 'Module:Disambiguation/templates' not found.{{#invoke:Disambiguation|isDisambiguationPage|Black swan (disambiguation)}}→ Lua error in package.lua at line 80: module 'Module:Disambiguation/templates' not found.
You can also use magic words like {{SUBJECTPAGENAME}}:
{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}}→ Lua error in package.lua at line 80: module 'Module:Disambiguation/templates' not found.
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
contentis 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
pageNameis 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.