Module:Format title
Appearance
§
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Usage
Links and formats article titles in body text for use on disambiguation or other pages. Used by templates {{fti}}, {{ftq}}, and {{ftqi}}.
- Function p._italic italicizes the non-parenthetical portion (or, optionally, only the parenthetical portion) of its argument (typically a page name).
- Function p._quotes encloses the non-parenthetical portion (or, optionally, only the parenthetical portion) of its argument (typically a page name) in quotation marks.
{{#invoke:Format title|function_name|article_title}}
local p = {}
function p.italic(frame)
frame = frame or mw.getCurrentFrame()
local title = frame.args[1]
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
local result
result = string.format("<i>%s</i> %s", prefix, parentheses)
return result
end
function p.quotes(frame)
frame = frame or mw.getCurrentFrame()
local title = frame.args[1]
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
local result
result = string.format("\"%s\" %s", prefix, parentheses)
return result
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Format title'
})
return p._main(args, frame)
end
return p