Moduł:Sprawdź

Z Wikibooks, biblioteki wolnych podręczników.
 Dokumentacja modułu [zobacz] [edytuj] [historia] [odśwież]

Ten moduł zapewnia platformę programistyczną dla tworzenia szablonów budujących przypadki testowe szablonów Wikibooksa. Przypadki testowe mogą być tworzone ręcznie, aczkolwiek te tworzone za pomocą szablonów opartych na module Lua, takim jak niniejszy moduł, mają taką zaletę, że argumenty szablonu muszą być wprowadzone jedynie jednokrotnie, co zmniejsza nakład pracy konieczny do tworzenia testów, a także zmniejsza ryzyko występowania błędów w danych wejściowych.

Porównaj

Ta funkcja jest obecnie wykorzystywana przez szablon {{Przypadek testowy}}.

Parametry

Funkcja do wykrywania wywołań szablonów z nierozpoznanymi, pustymi lub przestarzałymi parametrami. Należy ją wywołać ze wszystkimi możliwymi parametrami jakie przyjmuje szablon podlegający sprawdzaniu.

Opis parametrów
pole opis status uwagi
bez nazwy konfiguracja działania wymagany klasa lub klasa odstęp suffix
inny deklaracja pola obsługiwanego w szablonie opcjonalny txt, num, num?, uri, uri?, old, ^…$ lub pusty
Konfiguracja
  • klasa – ciąg znaków bez spacji umieszczany jako wartość atrybutu class w tagu <span> z wygenerowanym raportem
  • odstęp – ciąg znaków odstępu oddzielający pozostałą treść konfiguracji, jeśli zawiera znak nowej linii to przed wygenerowanym raportem jest również umieszczany znak nowej linii
  • suffix – treść dołączana po wygenerowanym raporcie, zwykle deklaracja technicznej kategorii
Sprawdzanie parametrów
  • pusty – parametr jest opcjonalny, jest to najczęściej stosowany sposób użycia
  • txt – oczekiwany jest dowolna niepusta wartość pola
  • num – sprawdzanie czy przekazana wartość jest liczbą
  • num? – sprawdzanie czy przekazana wartość jest pusta lub jest liczbą
  • uri – sprawdzanie czy przekazana wartość jest linkiem obsługiwanym przez MediaWiki
  • uri? – sprawdzanie czy przekazana wartość jest pusta lub jest linkiem
  • old – informuje, że przekazywany parametr jest przestarzały
  • ^…$ – tekst rozpoczynający się znakiem ^ i zakończony na $ w całości traktowany jest jako wyrażenie regularne Lua wskazującego prawidłowy parametr
Przykład
{{#invoke:Sprawdź|Parametry|=problemy-w-szablonie [[Kategoria:Błędy wywołań w szablonie]]|argument1=|argument2=}}

odn

Funkcja sprawdzająca prawidłowość parametrów w {{odn}}.
return {
	["NazwaKategoriiSprawdzaniaParametrówSzablonu"]=function()
		return "Szablony z dodatkową opcją sprawdzania parametrów";
	end;
	["UsuńKategorięSprawdzaniaParametrówSzablonu"]=function(frame)
		local wikikod=frame.args[1];
		local sprawdz_modul=require("Module:Sprawdź");
		local kategoria_sprawdzania_parametrow=sprawdz_modul["NazwaKategoriiSprawdzaniaParametrówSzablonu"]();
		local specjalne_modul=require("Module:Specjalne");
		return specjalne_modul["UsuńŚciśleOkreśloneKategorie"]{[1]=wikikod,[2]=kategoria_sprawdzania_parametrow,}
	end;
	["Porównaj"] = function(frame)
		local config = frame:getParent().args[""] or ""
		local options = mw.text.split(config, "|")
		local templateName = mw.text.trim(options[1])
		if #templateName == 0 then
			local title = mw.title.getCurrentTitle()
			if title.namespace == 10 then
				templateName = mw.ustring.match(title.text, "^(.-)/opis")
					or mw.ustring.match(title.text, "^(.-)/test")
					or mw.ustring.match(title.text, "^(.-)/brudnopis")
					or title.text
			end
			if #templateName == 0 then
				mw.log("brak nazwy szablonu")
				return
			end
		end
	
		local templateTitle = mw.title.new(templateName, 10)
		if templateTitle.id == 0 then
			mw.log("szablon '"..templateName.."' nie istnieje")
			return
		end
		
		local sandboxName = templateName.."/brudnopis"
		local sandboxTitle = mw.title.new(sandboxName, 10)
		if sandboxTitle.id == 0 then
			mw.log("brudnopis '"..sandboxName.."' nie istnieje")
			return
		end
		
		local i = 2
		local showparams = true
		local showinfo = true
		local vertical = false
		while i <= #options do
			local option = mw.text.trim(options[i])
			if option == "bez wikikodu" then
				showparams = false
			elseif option == "bez opisu" then
				showinfo = false
			elseif option == "pionowo" then
				vertical = true
			end
			
			i = i + 1
		end
	
		local templateParams = {}
		local params = {}
		for k, v in pairs(frame:getParent().args) do
			if k ~= "" then
				templateParams[k] = v
				table.insert(params, k)
			end
		end
	
		local result = {}
		table.insert(result, '<table style="width: 100%;">')
		
		if showparams and (#params > 0) then
			local compare = function(a, b)
				-- return a < b
				if (type(a) == "number") and (type(b) == "number") then
					return a < b
				end
				
				if (type(a) == "string") and (type(b) == "string") then
					return a < b
				end
				
				if (type(a) == "number") and (type(b) == "string") then
					return true
				end
				
				return false
			end
			
			table.sort(params, compare)
			table.insert(result, "<caption><code>&#x7B;&#x7B;")
			table.insert(result, templateName)
			for i, k in ipairs(params) do
				table.insert(result, " &#x7C; ")
				local p = mw.text.nowiki(tostring(k))
				local v = mw.text.nowiki(templateParams[k])
				table.insert(result, p)
				table.insert(result, " = ")
				table.insert(result, v)
			end
			table.insert(result, "&#x7D;&#x7D;</code></caption>")
		end
		
		local templateResult = frame:expandTemplate{ title=templateName, args=templateParams}
		local sandboxResult = frame:expandTemplate{ title=sandboxName, args=templateParams}
		
		if templateResult and string.match(templateResult, "^{|") then
			templateResult = "\n"..templateResult
		end
		if sandboxResult and string.match(sandboxResult, "^{|") then
			sandboxResult = "\n"..sandboxResult
		end
		
		if vertical and showinfo then
			table.insert(result, '<tr><th style="width: 15em">[[Szablon:')
			table.insert(result, templateName)
			table.insert(result, '|Szablon]]</th><td>')
			table.insert(result, templateResult)
			table.insert(result, '</td></tr><tr><th>[[Szablon:')
			table.insert(result, sandboxName)
			table.insert(result, '|Brudnopis szablonu]]</th><td>')
			table.insert(result, sandboxResult)
			table.insert(result, '</td></tr>')
		elseif vertical then
			table.insert(result, '<tr><td>')
			table.insert(result, templateResult)
			table.insert(result, '</td></tr><tr><td>')
			table.insert(result, sandboxResult)
			table.insert(result, '</td></tr>')
		else
			if showinfo then
				table.insert(result, '<tr><th style="width: 50%;">[[Szablon:')
				table.insert(result, templateName)
				table.insert(result, '|Szablon]]</th><th style="width: 50%;">[[Szablon:')
				table.insert(result, sandboxName)
				table.insert(result, '|Brudnopis szablonu]]</th></tr>')
			end
			
			table.insert(result, '<tr style="vertical-align: top;"><td>')
			table.insert(result, templateResult)
			table.insert(result, '</td><td>')
			table.insert(result, sandboxResult)
			table.insert(result, '</td></tr>')
		end
		
		table.insert(result, "</table>")
		return table.concat(result)
	end,

	["Parametry"] = function(frame)
		local pf=frame:getParent();
		local unknown = {}
		local invalid = {}
		local deprecated = {}
		local templateName;

		local function argName(arg)
			local span = mw.html.create('span');
			span:css('white-space','pre');
			span:wikitext(arg);
			return type(arg) ~= "string" and tostring(arg) or ('"'..tostring(span:allDone())..'"');
		end
		
		local ramka_modul=require("Module:Ramka");
		
		local tabelka1=ramka_modul.RozpakujArgumenty(frame.args["bez argumentów szablonu"]);
		local tabelka2=ramka_modul.RozpakujArgumenty(pf.args["bez argumentów szablonu"]);
		
		local parametry_modul=require("Module:Parametry");
		
		local tabelka_bez_argumentow=parametry_modul["ŁączDwieTabele"](tabelka1,tabelka2)

		local required = {};	
		local repeated = {};
		local konieczne = {};
		local empty = {};
		local noempty = {};
		
		local tabelka_argumentow_systemowych_funkcji={
			["nazwa przestrzeni nazw"]="",
			["nazwa jednostki"]="txt",
			["typ jednostki"]="txt",
			["tytuł przestrzeni nazw"]="",
			["tytuł jednostki"]="txt",
			["rodzaj jednostki"]="txt",
			["strona główna dla dzieci"]="txt",
			["strona główna projektu"]="txt",
			["usuń dodatkowe informacje"]="",
			["usuń ostrzeżenie"]="",
			["usuń linkowanie"]="",
			["bez dodatkowych sprawdzeń"]="",--parametr systemowy szablonu do nieuruchamiania tej funkcji
		};--tabelka powyższa jest tabelką argumentów systemowych tej funkcji tego modułu
        
        local tabelka_argumentow_dodatkowych_funkcji={
        	["bez argumentów szablonu"]="", --zawiera w sobie argumenty szablonu - oddzielone średnikem, których szablon nie może zawierać w wywołaniu
        	["dodaj parametry pudełka"]="", --dodaje parametry funkcji: Ogólne pudełko, modułu Pudełko
        };
        
	    local tabelka_argumentow_systemowych_szablonu={
	    	["bez kategorii"]="",--parametr systemowy szablonu, by kategorie się nie pojawiały
	    	["nazwij jednostką"]="",--parametr systemowy funkcji mówiący, czy dowolną jednostkę nazwać po prostu jednostką
	    };--tabelka powyższa jest tabelką argumentów systemowych szablonu wywołującego tę funkcję tego modułu
	    
	    local tabelka_parametrow_rodzica={};
		local parametry_rodzica=parametry_modul.CzyTak(pf.args["potomek"])and pf.args["parametry rodzica"];
		local szablonowe_modul=require("Module:Szablonowe");
	    if(parametry_rodzica)then
	        tabelka_parametrow_rodzica=ramka_modul.RozpakujParametry(parametry_rodzica);
	        templateName=pf.args["nazwa szablonu rodzica"] or szablonowe_modul.NazwaSzablonu(pf:getTitle());
	    else
	    	tabelka_parametrow_rodzica=pf.args;
	    	templateName=szablonowe_modul.NazwaSzablonu(pf:getTitle());
	    end;
	    
	    local czy_dodaj_parametry_pudelka=parametry_modul.CzyTak(frame.args["dodaj parametry pudełka"]);
	    
	    if(czy_dodaj_parametry_pudelka)then--dodaje parametry pudełka
	    	tabelka_argumentow_systemowych_szablonu["parametry pudełka"]="";
	    	tabelka_argumentow_systemowych_szablonu["bez błędu"]="";
	    	tabelka_argumentow_systemowych_szablonu["bez szczegółów"]="";
	    	--dodaje parametry nienazwane i dla parametru: 1, którego ewentualną pierwszą nazwą jest: cel--
	    	local maksimum=p.MaksymalnaLiczbaParametruNienazwanegoTablicy(tabelka_parametrow_rodzica);
	    	for i=1,maksimum,1 do
	    		if(i>1)then
	    		    tabelka_argumentow_systemowych_szablonu[i]="txt!";
	    		else
	    		    tabelka_argumentow_systemowych_szablonu[1]="txt!;cel";
	    		end;
	    	end;
	    	tabelka_argumentow_systemowych_szablonu["cel"]="txt!;1"
	    end;
	    
	    local tablica_mikroszablonow={
	       ["{{+}}"]=";",
	       ["{{!+}}"]="^",
	       ["{{+!}}"]="$",
	    };
		tabelka_bez_argumentow=parametry_modul["UsuńElementyTabeli"](tabelka_bez_argumentow,tabelka_argumentow_systemowych_funkcji);
		tabelka_bez_argumentow=parametry_modul["UsuńElementyTabeli"](tabelka_bez_argumentow,tabelka_argumentow_systemowych_szablonu);
		
		local zmienna_sprawdzania_parametrow=pf.args["zmienna sprawdzania parametrów"];
		local zmienne_dodane={};
		if(zmienna_sprawdzania_parametrow)then
			local tabelka_zmiennych=mw.text.split(zmienna_sprawdzania_parametrow,";;",false);
			for poz,war in ipairs(tabelka_zmiennych)do
				local zmienna,wartosc=mw.ustring.match(war,"^%s*(.+)%s*=%s*(.*)%s*$")
				if((zmienna)and(wartosc))then
					zmienna=mw.text.trim(zmienna);
					wartosc=mw.text.trim(wartosc);
					zmienne_dodane[tonumber(zmienna) or mw.ustring.gsub(zmienna,"{{[^{}]+}}",tablica_mikroszablonow)]=wartosc;
				end;
			end;
		end;
		
		local zmienne_konieczne=function(tab,czy_odjete)
			for k, v in pairs(tab)do
				if(czy_odjete 
					or ((not tabelka_argumentow_systemowych_funkcji[k]) 
						    and (not tabelka_argumentow_systemowych_szablonu[k]) 
						    and (not tabelka_bez_argumentow[k])
					   )
			      )then
					local wydziel=mw.ustring.match(v,"^%s*(^.*$%s*%??%s*!?)%s*");
					if wydziel and mw.ustring.match(wydziel, "!%s*$") then
						required[k] = true
					elseif mw.ustring.match(mw.ustring.match(v,"^([^;]*!?)%s*"), "!%s*$") then
						required[k] = true
					end
				end;
			end;
		end;
		zmienne_konieczne(frame.args,false);
		zmienne_konieczne(zmienne_dodane,true);
		zmienne_konieczne(tabelka_argumentow_systemowych_funkcji,true);
        zmienne_konieczne(tabelka_argumentow_systemowych_szablonu,true);
        
		local emptyArg = false
		
	    local obslugiwane=function(k)
	    	local kind=(not tabelka_argumentow_dodatkowych_funkcji[k]) and ((not tabelka_bez_argumentow[k])
			               and (tabelka_argumentow_systemowych_funkcji[k] 
			                     or tabelka_argumentow_systemowych_szablonu[k] 
			                  	 or zmienne_dodane[k] 
			                  	 or frame.args[k]));
			return kind;
	    end;
	    local tab={};
	    
	    local function inne_elementy_konieczne(k)
	    	local element=tab[k]
			if(element)then
				for name2,wartosc in pairs(element)do
					if(name2~=k)then
					   	if((wartosc[1])and(not wartosc[2])and (not tabelka_parametrow_rodzica[name2]) and (obslugiwane(name2)))then
							return true;
					   	end;
					end;
				end;
			end;
			return false;
	    end;
	    
	    local function tab_inne_elementy_konieczne(k)
	    	local element=tab[k]
	    	local tab_konieczne={};
			if(element)then
				for name2,wartosc in pairs(element)do
					if(name2~=k)then
					   	if((wartosc[1])and(not wartosc[2])and (not tabelka_parametrow_rodzica[name2]) and (obslugiwane(name2)))then
							table.insert(tab_konieczne,argName(tonumber(name2) or name2));
					   	end;
					end;
				end;
			end;
			return tab_konieczne;
	    end;

	    local function inne_elementy_nieobslugiwane(k)
	    	local element=tab[k]
			if(element)then
				for name2, wartosc in pairs(element)do
					if(name2~=k)then
						if(not wartosc[1])then
							if(not wartosc[2] and not wartosc[3])then
								if((obslugiwane(name2))and(tabelka_parametrow_rodzica[name2])and(#tabelka_parametrow_rodzica[name2]>0))then
									return true;
								else
									return false;
								end;
							elseif(not wartosc[2] and wartosc[3])then
								return false;
							elseif(wartosc[2] and not wartosc[3])then
								if((obslugiwane(name2))and(tabelka_parametrow_rodzica[name2])and(#tabelka_parametrow_rodzica[name2]==0))then
									return true;
								else
									return false;
								end;
							end;
						end;
					end;
				end;
			end;
			return false;
	    end;
	    
	    local function tab_inne_elementy_z_mozliwymi_koniecznymi_niepustymi_wartosciami(k)
	    	local element=tab[k];
	    	local tab_konieczne_puste={};
			if(element)then
				for name2,wartosc in pairs(element)do
					if(name2~=k)then
					   	if((wartosc[4])and(not wartosc[2])and (not wartosc[3])and (tabelka_parametrow_rodzica[name2]) and(#tabelka_parametrow_rodzica[name2]==0) and (obslugiwane(name2)))then
							table.insert(tab_konieczne_puste,argName(tonumber(name2) or name2));
					   	end;
					end;
				end;
			end;
			return tab_konieczne_puste;
	    end;

	    local function tab_inne_elementy_z_mozliwymi_koniecznymi_pustymi_wartosciami(k)
	    	local element=tab[k];
	    	local tab_konieczne_puste={};
			if(element)then
				for name2,wartosc in pairs(element)do
					if(name2~=k)then
					   	if((not wartosc[4])and(not wartosc[2])and (not wartosc[3])and (tabelka_parametrow_rodzica[name2]) and(#tabelka_parametrow_rodzica[name2]>0) and (obslugiwane(name2)))then
							table.insert(tab_konieczne_puste,argName(tonumber(name2) or name2));
					   	end;
					end;
				end;
			end;
			return tab_konieczne_puste;
	    end;

	    local function inne_elementy_z_mozliwymi_koniecznymi_niepustymi_wartosciami(k)
	    	local element=tab[k];
	    	local czy=false;
			if(element)then
				for name2, wartosc in pairs(element)do
					if(name2~=k)then
						if(wartosc[1])then
							if((wartosc[4])and(not wartosc[2])and(not wartosc[3]))then
								if((obslugiwane(name2))and((tabelka_parametrow_rodzica[name2])and(#tabelka_parametrow_rodzica[name2]==0)))then
									return true;
								end;
							end;
						end;
					end;
				end;
			end;
			return czy;
	    end;
	    
	    local function inne_elementy_z_mozliwymi_koniecznymi_pustymi_wartosciami(k)
	    	local element=tab[k];
	    	local czy=false;
			if(element)then
				for name2, wartosc in pairs(element)do
					if(name2~=k)then
						if(wartosc[1])then
							if((not wartosc[4])and(not wartosc[2])and(not wartosc[3]))then 
								if((obslugiwane(name2))and((tabelka_parametrow_rodzica[name2])and(#tabelka_parametrow_rodzica[name2]>0)))then
									return true;
								end;
							end;
						end;
					end;
				end;
			end;
			return czy;
	    end;
	    
	    local function inne_elementy_powtarzane_i_z_mozliwymi_dopuszczalnymi_pustymi_wartosciami(k)
	    	local element=tab[k];
	    	local czy=true;
			if(element)then
				for name2, wartosc in pairs(element)do
					if(name2~=k)then
						if(wartosc[1])then
							if(wartosc[2])then
								if(not wartosc[3])then 
									if((obslugiwane(name2))and(tabelka_parametrow_rodzica[name2]))then
										if(#tabelka_parametrow_rodzica[name2]==0)then
											return false;
										else
											return true;
										end;
									end;
								elseif((obslugiwane(name2))and(tabelka_parametrow_rodzica[name2]))then
									return true;
								end;
							end;
						end;
					end;
				end;
			end;
			return false;
	    end;

		local html_modul=require("Module:Html");
		
		for k, v in pairs(tabelka_parametrow_rodzica) do
			required[k] = false
			local kind=obslugiwane(k);
			local zapytajnik;
			local wykrzyknik;
			if (kind) then
				local kind2;local zmienne;
				kind2,zapytajnik,wykrzyknik,zmienne=mw.ustring.match(kind,"^%s*(!?^.*$)%s*(%??)%s*(!?)%s*;%s*(.-)%s*$");
				if((not kind2)or(not zmienne)or (not zapytajnik))then
					 kind2,zapytajnik,wykrzyknik,zmienne=mw.ustring.match(kind,"^%s*([^;]-)%s*(%??)%s*(!?)%s*;%s*(.-)%s*$");
				end;
				if((kind2)and(zmienne))then
					local tab2=mw.text.split(mw.text.trim(zmienne),"%s*;%s*",false);
					tab[k]={};
					for _,value in ipairs(tab2) do
						value=mw.text.trim(value);
						local indeks=tonumber(value) or  mw.ustring.gsub(value,"{{[^{}]+}}",tablica_mikroszablonow);
						local indeks2,wykrzyknik=mw.ustring.match(tostring(indeks),"^%s*(.*)%s*(!!?)%s*$");
						local indeks3,zapytajnik=mw.ustring.match(tostring(indeks2 or indeks),"^%s*(.*)%s*(%?)%s*$");
						local inne,indeks4=mw.ustring.match(tostring(indeks3 or indeks2 or indeks),"^%s*(!)%s*(.*)%s*$");
						tab[k][indeks4 or indeks3 or indeks2 or indeks]={((not inne) and true or false),
							                                             ((not wykrzyknik) and true or false),
							                                             ((not zapytajnik) and true or false),
							                                             ((not (wykrzyknik=="!!")) and true or false),
						                                                };
					end;
					kind=mw.ustring.gsub(kind2,"{{[^{}]+}}",tablica_mikroszablonow);
				else
					kind2,zapytajnik,wykrzyknik=mw.ustring.match(kind,"^%s*(!?%s*^.*$)%s*(%??)%s*(!?)%s*$");
					if(not kind2)or(not zapytajnik)then
						kind2,zapytajnik,wykrzyknik=mw.ustring.match(kind,"^%s*(.-)%s*(%??)%s*(!?)%s*$");
					end;
				    kind=mw.ustring.gsub(kind2,"{{[^{}]+}}",tablica_mikroszablonow);
				end;
			end;
			kind=kind and mw.text.trim(kind);
			if k == "" then
				emptyArg = v
			elseif not kind or inne_elementy_nieobslugiwane(k) then
				table.insert(unknown, argName(k))
			elseif inne_elementy_powtarzane_i_z_mozliwymi_dopuszczalnymi_pustymi_wartosciami(k) then
				table.insert(repeated, argName(k));	
			elseif inne_elementy_z_mozliwymi_koniecznymi_niepustymi_wartosciami(k) then
				table.insert(empty, k);	
			elseif inne_elementy_z_mozliwymi_koniecznymi_pustymi_wartosciami(k) then
				table.insert(noempty, k);
			elseif inne_elementy_konieczne(k) then
				table.insert(konieczne, k);	
			elseif (kind == "num") then
				if(zapytajnik~="?")then
					local n = tonumber(v)
					if not n then table.insert(invalid, argName(k)) end
			    else
					local n = (#v == 0) or tonumber(v)
					if not n then table.insert(invalid, argName(k)) end
				end;
			elseif (kind == "uri") then
				if(zapytajnik~="?")then
					local u = html_modul["SprawdźURL"](v)
					if not u then table.insert(invalid, argName(k)) end
			     else
					local u = (#v == 0) or html_modul["SprawdźURL"](v)
					if not u then table.insert(invalid, argName(k)) end	
				end;
			elseif (kind == "txt") then
				if(zapytajnik~="?")then
					if #v == 0 then table.insert(invalid, argName(k)) end;
				end;
			elseif (kind == "old") then
				table.insert(deprecated, argName(k))
			elseif(kind~="")then
				local function regex(kind)
					local tab_pattern_wykrzyknik_lub_nie_wzorow={};
					local pattern_poczatek=kind;
					local function funkcja_zbierajacy_dane_patternow(pattern_analiza_wzorow_koniunkcji)
						local tab_split_pattern_koniunkcji={};
						local pattern_poczatek=pattern_analiza_wzorow_koniunkcji;
						repeat
							local pattern_poczatek_2,pattern_koniec=mw.ustring.match(pattern_poczatek,"^%s*(!?%s*^.-$)%s*&%s*(.*)%s*$");
							if(pattern_poczatek_2 and pattern_koniec)then
								table.insert(tab_split_pattern_koniunkcji,pattern_poczatek_2);
								pattern_poczatek=pattern_koniec;
							else
								local pattern_caly=mw.ustring.match(pattern_poczatek,"^%s*(!?%s*^.-$)%s*$");
								if pattern_caly then
									table.insert(tab_split_pattern_koniunkcji,pattern_caly);
								end;
							end;
						until not pattern_poczatek_2;
						local tab_pattern_wykrzyknik_lub_nie_wzorow_koniunkcji={};
						for _,wartosc_elementu_koniunkcji in ipairs(tab_split_pattern_koniunkcji)do
							local wykrzyknik,pattern=mw.ustring.match(wartosc_elementu_koniunkcji,"^%s*(!?)%s*(^.-$)%s*$");
							table.insert(tab_pattern_wykrzyknik_lub_nie_wzorow_koniunkcji,{[1]=pattern,[2]=wykrzyknik});
						end;
						table.insert(tab_pattern_wykrzyknik_lub_nie_wzorow,tab_pattern_wykrzyknik_lub_nie_wzorow_koniunkcji);
					end;
					repeat
						local pattern_poczatek_2,pattern_koniec=mw.ustring.match(pattern_poczatek,"^%s*(!?%s*^.-$)%s*|%s*(.*)%s*$");
						if pattern_poczatek_2 and pattern_koniec then
							funkcja_zbierajacy_dane_patternow(pattern_poczatek_2);
				   			pattern_poczatek=pattern_koniec;
						else
							local pattern_caly=mw.ustring.match(pattern_poczatek,"^%s*(!?%s*^.-$)%s*$");
							if(pattern_caly)then
				                funkcja_zbierajacy_dane_patternow(pattern_caly);
							end;
			   		        break;
						end;
					until not pattern_poczatek_2;
					if(#tab_pattern_wykrzyknik_lub_nie_wzorow>0)then
						for _ , tab_pattern_koniunkcja in ipairs(tab_pattern_wykrzyknik_lub_nie_wzorow) do
							local czy=true;
							for _,tab_pattern_elementy_koniunkcji in ipairs(tab_pattern_koniunkcja)do
								local pattern=tab_pattern_elementy_koniunkcji[1];
								local wykrzyknik_negujacy_pattern=(tab_pattern_elementy_koniunkcji[2]=="!");
								if(pattern)then
									if((not wykrzyknik_negujacy_pattern and mw.ustring.match(v, pattern))or(wykrzyknik_negujacy_pattern and not mw.ustring.match(v, pattern)))then
											czy=czy and true;
											if(not czy)then
												break;
											end;
									else
										czy=false;
										break;
									end;
								end
							end;
							if(czy)then return true;end;
						end;
                        return false;
					end;
					return nil;
				end;
				if((zapytajnik)and((zapytajnik=="")or((zapytajnik=="?")and(#v>0))))then
                	local wynik=regex(kind);
                	if(type(wynik)~="nil")then
                		if(not wynik)then
                			table.insert(invalid, argName(k));
                		end;
                	end;
                end;
			end
		end;
		local missing = {}
		local function inny_element2(k)
	    	local element=tab[k]
			if(element)then
				for name2,wartosc in pairs(element)do
					if((wartosc[2])and(k~=name2))then
					   	if(tabelka_parametrow_rodzica[name2] and obslugiwane(name2))then
					   		return true;
					   	end;
					end;
				end;
			end;
			for name,value in pairs(tab)do
				for name2,wartosc in pairs(value)do
					if((wartosc[2])and(name2==k)and(name2~=name))then
						if((tabelka_parametrow_rodzica[name])and obslugiwane(name))then
							return true;
						end;
					end;
				end;
			end;
			return false;
		end;
		for k, v in pairs(required) do
			if v and not inny_element2(k) then
				table.insert(missing, argName(k))
			end
		end
        local function Szablon_z_sprawdz_parametry()
        	if(czy_not_category)then return "";end;
        	local nazwy_modul=require("Module:Nazwy");
        	local nazwa_szablonu=szablonowe_modul.NazwaSzablonu(nazwy_modul["PEŁNANAZWASTRONY"]());
        	if(templateName==nazwa_szablonu)then
        		local sprawdz_modul=require("Module:Sprawdź");
        		local nazwy_np_modul=mw.loadData("Module:Nazwy/Np");
        		return "[["..nazwy_np_modul.Category..":"..sprawdz_modul["NazwaKategoriiSprawdzaniaParametrówSzablonu"]().."|"..nazwy_modul["NAZWASTRONY"]().."]]";
        	end;
        	return "";
        end;
        local czy_missing=parametry_modul["CzySąElementyNumerowaneTablicy"](missing);
        local czy_konieczne=parametry_modul["CzySąElementyNumerowaneTablicy"](konieczne);
        local czy_unknown=parametry_modul["CzySąElementyNumerowaneTablicy"](unknown);
        local czy_invalid=parametry_modul["CzySąElementyNumerowaneTablicy"](invalid);
        local czy_deprecated=parametry_modul["CzySąElementyNumerowaneTablicy"](deprecated);
        local czy_repeated=parametry_modul["CzySąElementyNumerowaneTablicy"](repeated);
        local czy_empty=parametry_modul["CzySąElementyNumerowaneTablicy"](empty);
        local czy_noempty=parametry_modul["CzySąElementyNumerowaneTablicy"](noempty);
		if ((not czy_missing) and (not czy_konieczne) and (not czy_unknown) and (not czy_invalid) and (not czy_deprecated) and (not czy_repeated) and (not czy_empty) and (not czy_noempty) and(not emptyArg)) then
			return Szablon_z_sprawdz_parametry();
		end
		local czy_informacje=not parametry_modul.CzyTak(tabelka_parametrow_rodzica["usuń dodatkowe informacje"]);
 		local result;
 		if(czy_informacje)then
 			result=mw.html.create("span")
			result:addClass("problemy");
			result:addClass("error");
			result:css('white-space','pre-line');
			result:css('font-size','unset');
 		end;
		local typ;
		local typ_jednostki;
		local czy_nazwij_jednostka=parametry_modul.CzyTak(tabelka_parametrow_rodzica["nazwij jednostką"]);
		local czy_not_category=parametry_modul.CzyTak(tabelka_parametrow_rodzica["bez kategorii"]);
		
		----[""]=?---
			local config = frame.args[""]
			local class, space, category = string.match(config or "", "^%s*(%S+)(%s+)(.-)%s*$")
			local nl = space and string.match(space, "\n") or ""
			class = class or config
		----
		
		if(((czy_informacje)and(not czy_nazwij_jednostka))or((category)and((not czy_not_category)and(mw.ustring.match(category,"%%s.-%%s")))))then
 			--local frame2=pf:newChild{args = {["obsługiwane jednostki jako nieopisowe strony"]="tak"}}
 			local pudelko_modul=require("Module:Pudełko");
	    	typ_jednostki=pudelko_modul["Typ jednostki 2"]{args={
	    		["obsługiwane jednostki jako nieopisowe strony"]="tak",
	    		["nazwa przestrzeni nazw"]=pf and pf.args["tytuł przestrzeni nazw"] or frame.args["tytuł przestrzeni nazw"],
	    		["nazwa jednostki"]=pf and pf.args["tytuł jednostki"] or frame.args["tytuł jednostki"],
	    		["typ jednostki"]=pf and pf.args["rodzaj jednostki"] or frame.args["rodzaj jednostki"],
	    	},};
	    	if(typ_jednostki=="artykuł")then
	    		typ="(artykuły)";
	    	elseif(typ_jednostki=="artykuł dla dzieci")then
	    		typ="(artykuły dla dzieci)";
	    	elseif(typ_jednostki=="strona użytkownika")then
	    		typ="(strony użytkowników)";
	    	elseif(typ_jednostki=="strona brudnopisu projektu")then
	    		typ="(strony brudnopisu projektu)";
	    	else
	    		typ="(strony niepodręcznikowe)";
	    	end;
	    else
	    	typ=nil;
	    end;
	    if(czy_informacje)then
	    	if(not czy_nazwij_jednostka)then
	 			if typ_jednostki=="artykuł" or typ_jednostki=="artykuł dla dzieci" or typ_jednostki=="strona użytkownika" or typ_jednostki=="strona brudnopisu projektu" then
 					result:css("display", "none");
 					result:css("color","black");
 				else
 					result:css("color", "red")
 				end
 			else
 				 result:css("color", "red")
 			end;
	    end;
	    local czy_warning=not parametry_modul.CzyTak(tabelka_parametrow_rodzica["usuń ostrzeżenie"]);
	    local message;
 		if(czy_informacje or czy_warning)then
 			message=mw.html.create()
			if emptyArg then
				message:wikitext("Podano parametr o nazwie pustej o wartosci: |=", emptyArg, "|.<br/>")
			end
		
			if czy_missing then
				message:wikitext("Brakujące pola, które powinny być koniecznie podane: ", mw.text.listToText(missing), ".<br/>")
			end

            if czy_konieczne then
            	for _,_konieczne in ipairs(konieczne) do
				    message:wikitext("Konieczne pola, które powinny być używane z innymi parametrami, dla "..argName(_konieczne)..": "..mw.text.listToText(tab_inne_elementy_konieczne(_konieczne))..".<br/>")
				end;
            end
		
			if czy_invalid then
				message:wikitext("O nieprawidłowej wartości pola: ", mw.text.listToText(invalid), ".<br/>")
			end

			if czy_unknown then
				message:wikitext("Nieznane pola używane przez szablon: ", mw.text.listToText(unknown), ".<br/>")
			end

			if czy_deprecated then
				message:wikitext("Przestarzałe pola, które są obsługiwane, ale których nie powinno się raczej używać: ", mw.text.listToText(deprecated), ".<br/>")
			end
		
			if czy_repeated then
				message:wikitext("Pola o odpowiedniej podanej wartości, które nie powinne być używane z innymi parametrami lub z tymi podanymi: ", mw.text.listToText(repeated), ".<br/>")
			end
			if czy_empty then
				for _,_empty in ipairs(empty) do
				    message:wikitext("Dla pola "..argName(_empty).." wykryto wartości z pustymi polami: "..mw.text.listToText(tab_inne_elementy_z_mozliwymi_koniecznymi_niepustymi_wartosciami(_empty))..", które powinny być niepuste.<br/>")
				end;
			end
			if czy_noempty then
				for _,_noempty in ipairs(noempty) do
				    message:wikitext("Dla pola "..argName(_noempty).." wykryto wartości z niepustymi polami: "..mw.text.listToText(tab_inne_elementy_z_mozliwymi_koniecznymi_pustymi_wartosciami(_noempty))..", które powinny być niepuste.<br/>")
				end;
			end
		end;
        local warning;
        if(czy_warning)then
        	warning = mw.html.create('span');
        	warning:css('color','red');
        	warning:css('white-space','pre-line');
        	warning:css('word-break','break-all');
        	warning:addClass("problemy");
        end;
        if(templateName)then
        	mw.logObject(templateName, "templateName")
        	local dwukropek=mw.ustring.match(templateName,"^%s*:");
        	local nazwy_modul=require("Module:Nazwy");
			local nazwa_przestrzeni_strony=nazwy_modul["NAZWAPRZESTRZENI"](templateName);
			local wywolanie;local wywolanie2;
			local szablonowe_modul=require("Module:Szablonowe");
			if dwukropek or nazwa_przestrzeni_strony~="" then
                wywolanie=szablonowe_modul["PokazanieWywołaniaSzablonu"](templateName,tabelka_parametrow_rodzica);
                wywolanie2="{{"..templateName.."}}";
				if(parametry_modul.CzyTak(category))then 
					  templateName=mw.ustring.gsub(templateName,"^%s*:","");
					  if(not czy_not_category)then
					  	   if(typ)then
								category=mw.ustring.format(category,templateName,typ);
						   else
						   	    category=mw.ustring.format(category,templateName);
						   end;
						   category=pf:preprocess(category);
					  end;
					  class=mw.ustring.format(class,mw.ustring.gsub(templateName,"%s+","-"));
			    end;
			else
				wywolanie=szablonowe_modul["PokazanieWywołaniaSzablonu"](templateName,tabelka_parametrow_rodzica);
                wywolanie2="{{"..templateName.."}}";
				if(parametry_modul.CzyTak(category))then 
					local bez_pierwszej_litery=mw.ustring.match(templateName,"^.(.*)");
					local czy_jest_wielka_litera=mw.ustring.match(bez_pierwszej_litery,"%u");
					local szablon;
					if(not czy_jest_wielka_litera)then szablon=mw.getContentLanguage():lcfirst(templateName);else szablon=templateName;end;
					if(not czy_not_category)then
						if(typ)then
							category=mw.ustring.format(category,szablon,typ);
						else
							category=mw.ustring.format(category,szablon);
						end;
						category=pf:preprocess(category);
					end;
					class=mw.ustring.format(class,mw.ustring.gsub(szablon,"%s+","-"));
				end;
			end
			if(czy_warning)then
				local strong = mw.html.create('strong');
				strong:wikitext("Wywołanie ")
				local span = mw.html.create('span');
				span:css('font-weight','normal');
				span:css('white-space','pre');
				span:css('color',"brown");
				span:wikitext(wywolanie);
				local strong2=mw.html.create('strong');
				strong2:wikitext(" z wykrytymi parametrami z nieprawidłościami:<br/>");
				warning:node(strong);
				warning:node(span);
				warning:node(strong2);
			end;
			if(czy_informacje)then
				local strong = mw.html.create('strong');
 				strong:wikitext("Szablon "..wywolanie2.." z wykrytymi parametrami z nieprawidłościami:<br/>");
 				result:node(strong);
 			end;
        end;
        local czy_usun_linkowanie=parametry_modul.CzyTak(tabelka_parametrow_rodzica["usuń linkowanie"]);
        if(not czy_usun_linkowanie)then
        	local _ = mw.title.new("Module:Sprawdź/Wywołanie funkcji/Parametry").id;
        end;
        
        if(czy_informacje or czy_warning)then
        	message = tostring(message)
        end;
        if(czy_warning)then
 			warning:wikitext(message);
        	mw.addWarning(tostring(warning));
        end;
		 
		if czy_informacje and class then
		    result:addClass(class)
		end
        
        if(czy_informacje)then result:wikitext(message);end;
        local str_category;
		if not czy_not_category and category then
			str_category=category;
		else
			str_category="";
		end

		return nl..((czy_informacje)and tostring(result:allDone()) or "")..str_category..Szablon_z_sprawdz_parametry();
	end,

	["odn"] = function(frame)
		local pf = frame:getParent()
		local i = 1
		local problems = false
		local yeardetected = false
		while true do
			local arg = pf.args[i]
			if not arg then
				problems = i == 1 and "brak argumentów" or false
				break
			end
	 
			if (i > 5) or yeardetected then
				problems = "za dużo argumentów pozycyjnych"
				break
			end
	 
			if #arg == 0 then
				problems = "pusty argument"
				break
			end
	 
			if arg ~= mw.text.trim(arg) then
				problems = "nieoczekiwane odstępy na początku lub końcu argumentu"
				break
			end
	 
			if string.match(arg, "^%d+%l?$") then
				yeardetected = true
				if i == 1 then
					problems = "rok musi być ostatnim parametrem po nazwiskach autorów"
					break
				end
			elseif string.match(arg, "^s[%-%.:]%s*%d+") then
				problems = "prawdopodobnie nieprawidłowo podany numer strony"
				break
			elseif string.match(arg, "%s%s") then
				problems = "podwójne odstępy"
				break
			elseif mw.ustring.match(arg, "^%a+%d") then
				if not mw.ustring.match(arg, "^[%u%d]+$") then
					problems = "prawdopodobnie sklejone argumenty (brak pionowej kreski)"
					break
				end
			elseif mw.ustring.match(arg, "^OdeB ") then
				-- [[Ordre de Bataille]]
			elseif mw.ustring.match(arg, "^%u%l+%u") then
				local justification = {
					["De"] = true,
					["Del"] = true,
					["Di"] = true,
					["Le"] = true,
					["Mac"] = true,
					["Mc"] = true,
					["Te"] = true, -- TeSelle
					["Sar"] = true, -- SarDesai
					["Van"] = true, -- VanBuren
					["La"] = true, -- LaSalle
				}
				if not justification[mw.ustring.match(arg, "^%u%l+")] then
					problems = "prawdopodobnie sklejone argumenty (brak pionowej kreski)"
					break
				end
			end
	 
			i = i + 1
		end
	 
		if not problems then
			local odn = pf.args.odn
			if odn and ((#odn ~= 1) or (odn < "a") or (odn > "z")) then
				problems = "nieoczekiwany parametr odn"
			end
		end
	 
	 	if not problems then
	 		local s = pf.args.s
	 		if s and string.match(s, "&[a-z]+;") then
	 			problems = "użyto encji HTML w numerze strony"
	 		end
	 	end
	 
		if not problems then
			if pf.args.strona or pf.args.ss or pf.args.strony or pf.args.p or pf.args.page or pf.args.pp or pf.args.pages then
				problems = "przestarzały parametr z numerem strony"
			end
		end
	
	 	if not problems then
	 		return nil
	 	end
	 	
	 	local result = mw.html.create("span"):addClass("problemy-w-odn")
	    local frame2=pf:newChild{args = {["obsługiwane jednostki jako nieopisowe strony"]="tak"}}
	    local typ_jednostki=require("Module:Pudełko")["Typ jednostki 2"](frame2)
	    if typ_jednostki=="artykuł" or typ_jednostki=="artykuł dla dzieci" or typ_jednostki=="strona użytkownika" or typ_jednostki=="strona brudnopisu projektu" then
	 		result:css("display", "none")
	 	else
	 		result:css("color", "red")
	    end
	    local typ;
	    if(typ_jednostki=="artykuł")then 
	    	typ="artykuły";
	    elseif(typ_jednostki=="artykuł dla dzieci")then
	    	typ="artykuły dla dzieci";
	    elseif(typ_jednostki=="strona użytkownika")then
	    	typ="strony użytkowników";
	    elseif(typ_jednostki=="strona brudnopisu projektu")then
	    	typ="strony brudnopisu projektu";
	    else
	    	typ="strony niepodręcznikowe";
	    end;
	    local kategorie_modul=require("Module:Kategorie");
	    local str_kategoria=kategorie_modul.Kategoria{args={[1]="Szablon odn ("..typ..") do sprawdzenia"}};
 		result:wikitext(str_kategoria);
	 	result:wikitext("ODN: ", problems)
	 	return tostring(result)
	end,
	
	["Wikidane"] = function(frame)
		local property = frame.args.cecha
		local field = frame.args.pole
		local value = frame.args[1]
		if not property or not field then
			return
		end
		
		if not value then
			value = frame:getParent().args[field]
			if not value or (#value == 0) then
				return
			end
		end
		
		local entity = mw.wikibase.getEntity()
		if not entity or not entity.claims or not entity.claims[property] then
			return
		end
		
		for i, v in ipairs(entity.claims[property]) do
			if v.mainsnak.snaktype == "value" then
				if value == v.mainsnak.datavalue.value then
					return
				end
			end
		end
	
		local template = frame:getParent():getTitle()
		local infobox = mw.ustring.match(template, "^Szablon:(.- infobox)$")
		return mw.ustring.format("[[Kategoria:%s – niezgodność w Wikidanych – %s – %s]]", infobox and "Infoboksy" or "Szablony", infobox or template, field)
	end,

	["bez parametrów"] = function(frame)
		for k, v in pairs(frame:getParent().args) do
			return nil
		end
		
		return "tak"
	end,

	["pole z hostem"] = function (frame)
		local host = frame.args.host
		if host and (#host > 0) then
			for k, v in pairs(frame:getParent().args) do
				local link = string.match(v, "[hH][tT][tT][pP][sS]?://[%S]+")
				if link then
					local uri = mw.uri.new(link)
					local valid, _ = mw.uri.validate(uri)
					if valid and uri.host and (#uri.host > 0) then
						if host == uri.host then
							mw.logObject({k, link}, "cały")
							return k
						end
						
						if #host < #uri.host then
							local s1 = '.'..host
							local s2 = string.sub(uri.host, -#s1)
							if s1 == s2 then
								mw.logObject({k, link}, "fragment")
								return k
							end
						end
					end
				end
			end
		end
	end,
	
	["pola z gołymi linkami"] = function (frame)
		local result = {}
		for k, v in pairs(frame:getParent().args) do
			local link = string.match(v, "^[hH][tT][tT][pP][sS]?://[%S]+")
			if link then
				local justified = frame.args[k]
				if not justified then
					mw.logObject(v,k)
					table.insert(result, '"'..k..'"')
				end
			end
		end
		
		return mw.text.listToText(result)
	end,
}