Мазмунга өтүү

Модуль:data/magic words

Wiktionary дан

This module contains data relating to the MediaWiki magic words which are enabled on the English Wiktionary.

There are three types of magic word:

  • Parser variables, which cannot take arguments (e.g. {{PAGENAME}}).
  • Parser functions, which take argument 0 after a colon (e.g. {{[[Template:#IF:foo|#IF:foo]]|bar|baz}}), and can take further arguments.
  • Transclusion modifiers, which are used as colon-separated prefixes to templates or other magic words (e.g. {{SUBST:foo}}). These can be stacked with each other (but see the priority key below.

Many magic words can act as a parser variable or parser function, but others can only be one or the other.

parser_variable
Specifies that the magic word can be used as a parser variable. The value is a wikilink target to a documentation page.
parser_function
Specifies that the magic word can be used as a parser function. In most cases, the value is a wikilink target to a documentation page; in a small number of cases, the value is a table, because the most suitable link depends on whether argument 1 (i.e. the first argument after a pipe) has been given. In such cases, the table has two keys: key [0] is the link target when argument 1 has not been given, and key [1] is the link target when it has. For example, compare the link targets for {{PROTECTIONEXPIRY:foo}} and {{PROTECTIONEXPIRY:foo|bar}}.
transclusion_modifier
Specifies that the magic word can be used as a transclusion modifier. The value is a wikilink target to a documentation page.
name
The canonical name for the magic word. In most cases, this will be the same as the key. Note that this should not be specified in the data directly, as it is generated automatically. Instead, the key aliases can be used to give a table of aliases for the magic word, which are automatically converted into table keys with the same data as the canonical name when the table is returned. The aliases key is not present in the returned data, however.
case_sensitive
Specifies that the magic word is case-sensitive. Case-sensitive magic words must be given in their canonical form (which is usually uppercase), and any aliases have the same case-sensitivity as the canonical name. If case_sensitive = false, the magic word must be given in uppercase. The distribution of case-sensitive and case-insensitive magic words is essentially random, with the split being close to 50/50.
priority
Only used with transclusion modifiers. Specifies the order they must be given in when stacked together. For instance, a magic word with priority 2 can only be stacked after one with priority 1 and stacked before one with priority 3; compare {{SUBST:MSG:foo}} (both modifiers applied to Template:foo), and {{MSG:SUBST:foo}} ( applied to Template:SUBST:foo).

local next = next

local date_and_time = "mw:Help:Magic words#Date and time"
local formatting = "mw:Help:Magic words#Formatting"
local labeled_section_transclusion = "mw:Extension:Labeled Section Transclusion"
local liquidthreads = "mw:Extension:LiquidThreads"
local localization = "mw:Help:Magic words#Localization"
local miscellaneous = "mw:Help:Magic words#Miscellaneous"
local namespaces = "mw:Help:Magic words#Namespaces"
local namespaces_2 = "mw:Help:Magic words#Namespaces 2"
local noexternallanglinks = "mw:Wikibase/Installation/Advanced configuration#noexternallanglinks"
local other = "mw:Help:Magic words#Other"
local page_names = "mw:Help:Magic words#Page names"
local parser_functions_ext = "mw:Help:Extension:ParserFunctions##" -- ## is not a typo
local statistics = "mw:Help:Magic words#Statistics"
local substitution = "mw:Manual:Substitution"
local technical_metadata = "mw:Help:Magic words#Technical metadata"
local technical_metadata_of_another_page = "mw:Help:Magic words#Technical metadata of another page"
local transclusion_modifiers = "mw:Help:Magic words#Transclusion modifiers"
local url_data = "mw:Help:Magic words#URL data"

local data = {}

for k, v in next, {
	["!"] = {
		parser_variable = other,
		case_sensitive = false
	},
	
	["#BABEL"] = {
		parser_function = "mw:Extension:Babel#Usage",
		case_sensitive = false
	},
	
	["#bcp47"] = { -- Case-sensitive lowercase.
		parser_function = localization,
		parser_variable = localization,
		case_sensitive = true
	},
	
	["#CATEGORYTREE"] = {
		parser_function = "mw:Extension:CategoryTree#The {{#categorytree}} parser function",
		case_sensitive = false
	},
	
	["#COMMASEPARATEDLIST"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["#dir"] = { -- Case-sensitive lowercase.
		parser_function = localization,
		parser_variable = localization,
		case_sensitive = true
	},
	
	["#EXPR"] = {
		parser_function = parser_functions_ext .. "expr",
		case_sensitive = false
	},
	
	["#FORMAL"] = {
		parser_function = localization,
		case_sensitive = true
	},
	
	["#FORMATDATE"] = {
		aliases = {"#DATEFORMAT"},
		parser_function = formatting,
		case_sensitive = false
	},
	
	["#IF"] = {
		parser_function = parser_functions_ext .. "if",
		case_sensitive = false
	},
	
	["#IFEQ"] = {
		parser_function = parser_functions_ext .. "ifeq",
		case_sensitive = false
	},
	
	["#IFERROR"] = {
		parser_function = parser_functions_ext .. "iferror",
		case_sensitive = false
	},
	
	["#IFEXIST"] = {
		parser_function = parser_functions_ext .. "ifexist",
		case_sensitive = false
	},
	
	["#IFEXPR"] = {
		parser_function = parser_functions_ext .. "ifexpr",
		case_sensitive = false
	},
	
	["#INVOKE"] = {
		parser_function = "mw:Extension:Scribunto#Usage",
		case_sensitive = false
	},
	
	["#LANGUAGE"] = {
		parser_function = localization,
		parser_variable = localization,
		case_sensitive = false
	},
	
	["#LQTPAGELIMIT"] = {
		parser_function = liquidthreads,
		case_sensitive = false
	},
	
	["#LST"] = {
		aliases = {"#SECTION"},
		parser_function = labeled_section_transclusion,
		case_sensitive = false
	},
	
	["#LSTH"] = {
		aliases = {"#SECTION-H"},
		parser_function = labeled_section_transclusion,
		case_sensitive = false
	},
	
	["#LSTX"] = {
		aliases = {"#SECTION-X"},
		parser_function = labeled_section_transclusion,
		case_sensitive = false
	},
	
	["#PROPERTY"] = {
		parser_function = "m:Wikidata/Notes/Inclusion syntax",
		case_sensitive = false
	},
	
	["#REL2ABS"] = {
		parser_function = parser_functions_ext .. "rel2abs",
		case_sensitive = false
	},
	
	["#SPECIAL"] = {
		parser_function = miscellaneous,
		case_sensitive = false
	},
	
	["#SPECIALE"] = {
		parser_function = miscellaneous,
		case_sensitive = false
	},
	
	["#STATEMENTS"] = {
		parser_function = "d:WD:How to use data on Wikimedia projects#Parser function",
		case_sensitive = false
	},
	
	["#SWITCH"] = {
		parser_function = parser_functions_ext .. "switch",
		case_sensitive = false
	},
	
	["#TAG"] = {
		parser_function = miscellaneous,
		case_sensitive = false
	},
	
	["#TARGET"] = {
		parser_function = "mw:Extension:MassMessage#Parser function delivery lists",
		case_sensitive = false
	},
	
	["#TIME"] = {
		parser_function = parser_functions_ext .. "time",
		case_sensitive = false
	},
	
	["#timef"] = { -- Case-sensitive lowercase.
		parser_function = parser_functions_ext,
		case_sensitive = true
	},
	
	["#timefl"] = { -- Case-sensitive lowercase.
		parser_function = parser_functions_ext,
		case_sensitive = true
	},
	
	["#TIMEL"] = {
		parser_function = parser_functions_ext .. "timel",
		case_sensitive = false
	},
	
	["#TITLEPARTS"] = {
		parser_function = parser_functions_ext .. "titleparts",
		case_sensitive = false
	},
	
	["#USELIQUIDTHREADS"] = {
		parser_function = liquidthreads,
		case_sensitive = false
	},
	
	["="] = {
		parser_variable = other,
		case_sensitive = false
	},
	
	["ANCHORENCODE"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["ARTICLEPATH"] = {
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["BASEPAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["BASEPAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["BIDI"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["CANONICALURL"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["CANONICALURLE"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["CASCADINGSOURCES"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["CONTENTLANGUAGE"] = {
		aliases = {"CONTENTLANG"},
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["CURRENTDAY"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTDAY2"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTDAYNAME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTDOW"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTHOUR"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTMONTH"] = {
		aliases = {"CURRENTMONTH2"},
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTMONTH1"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTMONTHABBREV"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTMONTHNAME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTMONTHNAMEGEN"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTTIME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTTIMESTAMP"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTVERSION"] = {
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["CURRENTWEEK"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["CURRENTYEAR"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["DEFAULTSORT"] = {
		aliases = {"DEFAULTCATEGORYSORT", "DEFAULTSORTKEY"},
		parser_function = technical_metadata,
		case_sensitive = true
	},
	
	["DIRECTIONMARK"] = {
		aliases = {"DIRMARK"},
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["DISPLAYTITLE"] = {
		parser_function = technical_metadata,
		case_sensitive = true
	},
	
	["FILEPATH"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["FORMATNUM"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["FULLPAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["FULLPAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["FULLURL"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["FULLURLE"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["GENDER"] = {
		parser_function = localization,
		case_sensitive = false
	},
	
	["GRAMMAR"] = {
		parser_function = localization,
		case_sensitive = false
	},
	
	["INT"] = {
		parser_function = localization,
		case_sensitive = false
	},
	
	["LC"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["LCFIRST"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["LOCALDAY"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALDAY2"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALDAYNAME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALDOW"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALHOUR"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALMONTH"] = {
		aliases = {"LOCALMONTH2"},
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALMONTH1"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALMONTHABBREV"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALMONTHNAME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALMONTHNAMEGEN"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALTIME"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALTIMESTAMP"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALURL"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["LOCALURLE"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["LOCALWEEK"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["LOCALYEAR"] = {
		parser_variable = date_and_time,
		case_sensitive = true
	},
	
	["MSG"] = {
		transclusion_modifier = transclusion_modifiers,
		priority = 2,
		case_sensitive = false
	},
	
	["MSGNW"] = {
		transclusion_modifier = transclusion_modifiers,
		priority = 2,
		case_sensitive = false
	},
	
	["NAMESPACE"] = {
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["NAMESPACEE"] = {
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["NAMESPACENUMBER"] = {
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["NOEXTERNALLANGLINKS"] = {
		parser_function = noexternallanglinks,
		parser_variable = noexternallanglinks,
		case_sensitive = false
	},
	
	["NS"] = {
		parser_function = namespaces_2,
		case_sensitive = false
	},
	
	["NSE"] = {
		parser_function = namespaces_2,
		case_sensitive = false
	},
	
	["NUMBERINGROUP"] = {
		aliases = {"NUMINGROUP"},
		parser_function = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFACTIVEUSERS"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFADMINS"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFARTICLES"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFEDITS"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFFILES"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFPAGES"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["NUMBEROFUSERS"] = {
		parser_function = statistics,
		parser_variable = statistics,
		case_sensitive = true
	},
	
	["PADLEFT"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["PADRIGHT"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["PAGEID"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["PAGELANGUAGE"] = {
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["PAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["PAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["PAGESINCATEGORY"] = {
		aliases = {"PAGESINCAT"},
		parser_function = statistics,
		case_sensitive = true
	},
	
	["PAGESIZE"] = {
		parser_function = technical_metadata_of_another_page,
		case_sensitive = true
	},
	
	["PLURAL"] = {
		parser_function = localization,
		case_sensitive = false
	},
	
	["PROTECTIONEXPIRY"] = {
		parser_function = {
			technical_metadata,
			technical_metadata_of_another_page
		},
		case_sensitive = true
	},
	
	["PROTECTIONLEVEL"] = {
		parser_function = {
			technical_metadata,
			technical_metadata_of_another_page
		},
		case_sensitive = true
	},
	
	["RAW"] = {
		transclusion_modifier = transclusion_modifiers,
		priority = 3,
		case_sensitive = false
	},
	
	["REVISIONDAY"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONDAY2"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONID"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONMONTH"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONMONTH1"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONSIZE"] = {
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONTIMESTAMP"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONUSER"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["REVISIONYEAR"] = {
		parser_function = technical_metadata_of_another_page,
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["ROOTPAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["ROOTPAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["SAFESUBST"] = {
		transclusion_modifier = substitution,
		priority = 1,
		case_sensitive = false
	},
	
	["SCRIPTPATH"] = {
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["SERVER"] = {
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["SERVERNAME"] = {
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["SITENAME"] = {
		parser_variable = technical_metadata,
		case_sensitive = true
	},
	
	["STYLEPATH"] = {
		parser_variable = technical_metadata,
		case_sensitive = false
	},
	
	["SUBJECTPAGENAME"] = {
		aliases = {"ARTICLEPAGENAME"},
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["SUBJECTPAGENAMEE"] = {
		aliases = {"ARTICLEPAGENAMEE"},
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["SUBJECTSPACE"] = {
		aliases = {"ARTICLESPACE"},
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["SUBJECTSPACEE"] = {
		aliases = {"ARTICLESPACEE"},
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["SUBPAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["SUBPAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["SUBST"] = {
		transclusion_modifier = substitution,
		priority = 1,
		case_sensitive = false
	},
	
	["TALKPAGENAME"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["TALKPAGENAMEE"] = {
		parser_function = page_names,
		parser_variable = page_names,
		case_sensitive = true
	},
	
	["TALKSPACE"] = {
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["TALKSPACEE"] = {
		parser_function = namespaces,
		parser_variable = namespaces,
		case_sensitive = true
	},
	
	["UC"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["UCFIRST"] = {
		parser_function = formatting,
		case_sensitive = false
	},
	
	["URLENCODE"] = {
		parser_function = url_data,
		case_sensitive = false
	},
	
	["USERLANGUAGE"] = {
		parser_variable = technical_metadata,
		case_sensitive = true
	},
} do
	data[k] = v
	if not v.name then
		v.name = k
	end
	local aliases = v.aliases
	if aliases then
		for i = 1, #aliases do
			data[aliases[i]] = v
		end
		v.aliases = nil
	end
end

return data