Difference between revisions of "Module:Italic title"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (allow the ability to specify the "noerror" parameter) |
blackwiki>Mr. Stradivarius (allow this to be called from Lua, and make it more compact) |
||
| Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
| − | function p. | + | function p._main(args, frame, title) |
| − | + | args = args or {} | |
| − | + | frame = frame or mw.getCurrentFrame() | |
| − | + | title = title or mw.title.getCurrentTitle() | |
| − | |||
| − | |||
| − | |||
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$') | local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$') | ||
| − | |||
| − | |||
| − | |||
local result | local result | ||
if prefix and parentheses and args.all ~= 'yes' then | if prefix and parentheses and args.all ~= 'yes' then | ||
| − | result = "'' | + | result = string.format("''%s'' %s", prefix, parentheses) |
else | else | ||
| − | result = "''" | + | result = string.format("''%s''", title.text) |
end | end | ||
| − | |||
| − | |||
if title.namespace ~= 0 then | if title.namespace ~= 0 then | ||
| − | result = | + | result = title.nsText .. ':' .. result |
end | end | ||
| + | return frame:callParserFunction('DISPLAYTITLE', result, args[1]) | ||
| + | end | ||
| − | + | function p.main(frame) | |
| − | + | local args = require('Module:Arguments').getArgs(frame, { | |
| − | ' | + | wrappers = 'Template:Italic title' |
| − | + | }) | |
| − | + | return p._main(args, frame) | |
| − | + | end | |
| − | end | ||
return p | return p | ||
Revision as of 23:37, 3 March 2015
| 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(args, frame, title)
args = args or {}
frame = frame or mw.getCurrentFrame()
title = title or mw.title.getCurrentTitle()
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
local result
if prefix and parentheses and args.all ~= 'yes' then
result = string.format("''%s'' %s", prefix, parentheses)
else
result = string.format("''%s''", title.text)
end
if title.namespace ~= 0 then
result = title.nsText .. ':' .. result
end
return frame:callParserFunction('DISPLAYTITLE', result, args[1])
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Italic title'
})
return p._main(args, frame)
end
return p