Module:Format title: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
function p._italic(args) |
function p._italic(args) |
||
local title = args[1] |
local title = args[1] |
||
⚫ | |||
-- local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$') |
|||
-- local result |
|||
-- result = string.format("<i>%s</i> %s", prefix, parentheses) |
|||
⚫ | |||
-- return result |
|||
end |
end |
||
Revision as of 18:50, 4 November 2015
§
![]() | 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 getArgs = require('Module:Arguments').getArgs
local p = {}
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame)
return p[funcName](args)
end
end
p.italic = makeInvokeFunc('_italic')
function p._italic(args)
local title = args[1]
return title
-- local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
-- local result
-- result = string.format("<i>%s</i> %s", prefix, parentheses)
-- return result
end
p.quotes = makeInvokeFunc('_quotes')
function p._quotes(args)
local title = args[1]
local prefix, parentheses = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
local result
result = string.format("\"%s\" %s", prefix, parentheses)
return result
end
return p