Jump to content

Module:Italic title/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Andy M. Wang (talk | contribs) at 17:47, 4 June 2016 (noinclude test (prevent redirect/transclusions affecting add'l pages?)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- 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("<i>%s</i> %s", prefix, parentheses)
	else
		result = string.format("<i>%s</i>", title.text)
	end
	if title.namespace ~= 0 then
		result = title.nsText:gsub('_', ' ') .. ':' .. 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 '<noinclude>' .. p._main(args, frame) .. '</noinclude>'
end

return p