Module:Italic title
Appearance
![]() | This Lua module is used on approximately 1,180,000 pages, or roughly 2% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | 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 depends on the following other modules: |
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)
-- Process the arguments.
local args
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
for k, v in pairs(frame.args) do
args = frame.args
break
end
else
args = frame
end
local title = mw.title.getCurrentTitle() -- Get the current page object.
-- 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 it exists.
if title.nsText and title.nsText ~= "" then
result = title.nsText .. ':' .. result
end
-- Call displaytitle with the text we generated.
return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )
end
return p