Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a24f35bf69f0227c

Jump to content

Module:Format title

From Wikipedia, the free encyclopedia

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

p.quotes = makeInvokeFunc('_quotes')

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

return p