Difference between revisions of "Module:Italic title"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (add support for all=yes) |
blackwiki>Mr. Stradivarius (Undid revision 560274954 by Mr. Stradivarius (talk) ok, something went wrong there) |
||
| Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
| − | function p.main( | + | function p.main() |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
local title = mw.title.getCurrentTitle() -- Get the current page object. | local title = mw.title.getCurrentTitle() -- Get the current page object. | ||
-- Find the parts before and after the disambiguation brackets, if any. | -- Find the parts before and after the disambiguation brackets, if any. | ||
| Line 21: | Line 10: | ||
-- italicise the whole title. | -- italicise the whole title. | ||
local result | local result | ||
| − | if prefix and brackets | + | if prefix and brackets then |
result = "''" .. prefix .. "'' " .. brackets | result = "''" .. prefix .. "'' " .. brackets | ||
else | else | ||
| Line 32: | Line 21: | ||
-- Call displaytitle with the text we generated. | -- Call displaytitle with the text we generated. | ||
return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result ) | return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result ) | ||
| − | end | + | end |
return p | return p | ||
Revision as of 10:02, 17 June 2013
| 40px | 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). |
| 40x40px | 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()
local title = mw.title.getCurrentTitle() -- Get the current page object.
-- Find the parts before and after the disambiguation brackets, if any.
local prefix, brackets = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
-- If brackets were found, italicise only the part before them. Otherwise
-- italicise the whole title.
local result
if prefix and brackets then
result = "''" .. prefix .. "'' " .. brackets
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