Module:Italic title
Revision as of 08:20, 21 August 2014 by blackwiki>Mr. Stradivarius (allow the ability to specify the "noerror" parameter)
| This Lua module is used on approximately 963,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. Transclusion count updated automatically (see documentation). |
| 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. |
This module implements {{italic title}} and {{italic dab}}. Please see the template pages for documentation.
-- 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