Difference between revisions of "Module:Sandbox/28bytes/acm"
Jump to navigation
Jump to search
blackwiki>28bytes (module test) |
blackwiki>28bytes (module test) |
||
| Line 5: | Line 5: | ||
local c = {}; | local c = {}; | ||
| − | if | + | if mw.ustring.find(frame.args[1],"q") ~= 0 then |
c = "\""; | c = "\""; | ||
| − | elseif | + | elseif mw.ustring.find(frame.args[1],"t") ~= 0 then |
c = "''"; | c = "''"; | ||
end | end | ||
Revision as of 07:39, 8 December 2018
gettitle
This function accepts an article title and formats it with quotes or italics as specified (useful for songs, albums and books.) It can also optionally add a "Did you know" indicator and/or Good Article indicator following the article title.
Arguments
- Formatting specifiers, in any order:
- Article title excluding the disamiguator (required)
- Disambiguator (optional)
Usage examples
For a song title with a parenthetical disambiguator that should not be in quotation marks:
{{#invoke:Sandbox/28bytes/acm|gettitle|?q|Cinema|(Yes song)}}- displays Lua error at line 16: attempt to index global 'args' (a nil value).
For a song title with a parenthetical that should be in quotation marks, as it is part of the title:
{{#invoke:Sandbox/28bytes/acm|gettitle|?q|I.G.Y. (What a Beautiful World)}}- displays Lua error at line 16: attempt to index global 'args' (a nil value).
For an album title without a parenthetical disambiguator:
{{#invoke:Sandbox/28bytes/acm|gettitle|?Gt|Move Like This}}- displays Lua error at line 16: attempt to index global 'args' (a nil value).
local p = {};
p.gettitle = function( frame )
local c = {};
if mw.ustring.find(frame.args[1],"q") ~= 0 then
c = "\"";
elseif mw.ustring.find(frame.args[1],"t") ~= 0 then
c = "''";
end
if frame.args[3] == {} then
return c .. "[[" .. args[2] .. "]]" .. c;
else
return "[[" .. args[2] .. " " .. args[3] .. "|" .. c .. args[2] .. c .. " " .. args[3] .. "]]";
end
end
return p