Przejdź do zawartości

Moduł:Navbox/title

Z Wikipedii, wolnej encyklopedii
 Dokumentacja modułu [stwórz] [odśwież]
local function titlePattern()
	local title = mw.title.getCurrentTitle()
	local textPattern = mw.ustring.gsub( title.fullText, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )
	if title.namespace == 0 then
		local lang = mw.getContentLanguage()
		local text1 = lang:ucfirst(textPattern)
		local text2 = lang:lcfirst(textPattern)
		if text1 ~= text2 then
			local c1 = mw.ustring.sub(text1, 1, 1)
			local c2 = mw.ustring.sub(text2, 1, 1)
			local tail1 = mw.ustring.sub(text1, 2)
			local tail2 = mw.ustring.sub(text2, 2)
			if (c1 ~= c2) and (tail1 == tail2) then
				textPattern = '['..c1..c2..']'..tail1
			end
		end
	end
	
	local result = "%[%[%s*"..textPattern.."%s*[|%]]"
	mw.logObject(result, 'titlePattern')
	return result
end

return {
	wikilinkPattern = titlePattern(),
}