Modulo:Categoria

Da Wikisource.

La documentazione per questo modulo può essere creata in Modulo:Categoria/man

local p = {}
local c = require('Modulo:Common')

function p.categorie(frame)
	baseName = frame.args[1]    -- es. "Testi di"
	names = frame.args[2]       -- es. "Tizio/Caio", opzionale
	sortName = c.stripAccents(mw.title.getCurrentTitle().subpageText) -- parte finale del nome pagina attuale senza accenti
	cat = ''
	if names then
		for k, v in pairs(mw.text.split(names, "/")) do
			cat = cat .. '[[Categoria:' .. baseName .. ' ' .. v .. '|' .. sortName .. ']]'
		end
		return cat
	else
		return '[[Categoria:' .. baseName .. '|' .. sortName .. ']]'
	end
end

function p.defaultSort(frame)
	sortString = frame.args[1] or ''
	if sortString == '' then
		if c.isNS0() then
			sortString = c.stripAccents(mw.title.getCurrentTitle().subpageText)
		else
			sortString = c.stripAccents(mw.title.getCurrentTitle().text)
		end
	end
	sortString = sortString:gsub('^ʼ', ''):gsub("^'", ''):gsub("^%.", ''):gsub("^%.", ''):gsub("^%.", ''):gsub("^ ", '')
	mw.log('DEFAULTSORT: ' .. sortString)
	return sortString
end

return p