You can edit almost every page by Creating an account and confirming your email.

Module:Format title

From EverybodyWiki Bios & Wiki
Revision as of 02:28, 7 April 2018 by WikiMaster (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

§

Usage

Links and formats article titles in body text for use on disambiguation or other pages. Used by templates {{fti}} and {{ftq}}.

  • 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]
	local prefix, parentheses = mw.ustring.match(title, '^(.+) (%([^%(%)]+%))$')
	local result
	if prefix and parentheses and args.all ~= 'yes' then	
		result = string.format("\'\'%s\'\' %s", prefix, parentheses)
	else
		result = string.format("\'\'%s\'\'", title)
	end
	return result
end

p.quotes = makeInvokeFunc('_quotes')

function p._quotes(args)
	local title = args[1]
	local prefix, parentheses = mw.ustring.match(title, '^(.+) (%([^%(%)]+%))$')
	local result
	if prefix and parentheses and args.all ~= 'yes' then
		result = string.format("\"%s\" %s", prefix, parentheses)
	else
		result = string.format("\"%s\"", title)
	end
	return result
end

return p

This module "Format title" is from Wikipedia if otherwise notified