މޮޑިއުލް:Italic title
This template is used on 580,000+ pages. To avoid large-scale disruption and unnecessary server load, any changes to this template should first be tested in its /sandbox or /testcases subpages, or in your own user space. The tested changes can then be added to this page in one single edit. Please consider discussing any changes on the talk page before implementing them. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
{{italic title}}. Please see the template page for documentation.
The above documentation is transcluded from މޮޑިއުލް:Italic title/doc. (edit | history) Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages. Subpages of this module. |
-- This module implements {{italic title}}.
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Italic title'
})
local title = mw.title.getCurrentTitle()
-- Find the parts before and after the disambiguation parentheses, if any.
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
-- If parentheses were found, italicise only the part before them. Otherwise
-- italicise the whole title.
local result
if prefix and parentheses and args.all ~= 'yes' then
result = "''" .. prefix .. "'' " .. parentheses
else
result = "''" .. title.text .. "''"
end
-- Add the namespace if we're not in mainspace.
if title.namespace ~= 0 then
result = mw.site.namespaces[title.namespace].name .. ':' .. result
end
-- Call displaytitle with the text we generated.
return mw.getCurrentFrame():callParserFunction(
'DISPLAYTITLE',
result,
args[1]
)
end
return p