Przejdź do zawartości

Moduł:Sandbox/Draco flavus/Test9

Z Wikiźródeł, wolnej biblioteki

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Sandbox/Draco flavus/Test9/opis

local p = {}
local pag = require("mw.ustring")
function p.test_na_kreske(frame)

-- Wywołanie: {{#invoke: Sandbox/Draco flavus/Test9 | test_na_kreske | Strona:PL Encyklopedyja powszechna 1860 T1.djvu|strona_p|strona_k|formatowanie}}
-- Wynik: jeśli w danym zakresie stron występuje na końcu kreska podaje numery stron i przenoszone słowo 
-- do wykorzystania w szablonie
	
    local SubPageResult = ''
    local SubPageName = ''
    local start = tonumber(frame.args[2])
    local stop = tonumber(frame.args[3])
    local substring = ''
    local wynik = ''
    local wynik1 = ''
    local PageA = ''
    local PageB = ''
    local p = ''
    local q = ''
    local formatowanie = frame.args[4]
    if formatowanie == nil then
    	formatowanie = "%01d"
    end
    for i = start, stop - 1, 1 do
    	SubPageName = frame.args[1] .. '/' .. string.format(formatowanie, i)
    	SP = mw.title.new(SubPageName):getContent()
    	if SP == nil then
    	else
	    	PageA = mw.ustring.match(SP, '(............. [^ ]*)<noinclude>.-</noinclude>$')
	    	if mw.ustring.sub(PageA, -1) == '-' then
	    		PageA = mw.ustring.sub(PageA, 1,-2)
	    		SubPageName=frame.args[1] .. '/' .. string.format(formatowanie, i + 1)
	    		SP = mw.title.new(SubPageName):getContent()
    		    if SP == nil then
				else
					p = mw.ustring.match(PageA, ' ([^ ]*)$')
					if mw.ustring.find(p, "'") then
						wynik = wynik .. '!!!!!!!!!!!!!!!!!!!!!!' .. i .. '   ' .. PageA .. '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br><br>'
					else
			    		PageB = mw.ustring.match(SP, '^<noinclude>.-</noinclude>(.-[ :.,!?;)”“…«»<].................)')
			    		q = mw.ustring.match(PageB,'(.-)[ :.,!?;)”“…«»<].*')
						if mw.ustring.sub(q, -1) == '’' then
							q = mw.ustring.match(frame.args[1],'(.-)’')
						end
			    		wynik = wynik .. i .. ' ' .. i + 1 .. ' ' .. PageA .. ' ■ '.. PageB .. '<br>' .. ' {{pp|' .. p .. '|' .. q .. '}}<br>'
			    		wynik1 = wynik1 .. 'python3.8 pwb.py replace -page:"' .. frame.args[1] .. '/' .. string.format(formatowanie, i) .. '" "' .. p .. '-<noinclude" "' .. '{{pp|' .. p .. '|' .. q .. '}}<noinclude" -always  -summary:"Bot zmienia na pp/pk" -pt:0; <br>'
			    		wynik1 = wynik1 .. 'python3.8 pwb.py replace -page:"' .. frame.args[1] .. '/' .. string.format(formatowanie, i + 1) .. '" "noinclude>' .. q .. '" "noinclude>' .. '{{pk|' .. p .. '|' .. q .. '}}" -always  -summary:"Bot zmienia na pp/pk" -pt:0; <br>'
					end
				end
			end
    	end
    	
    end
    return wynik .. '<br><br><br>' .. wynik1
    	

end

function p.test(frame)
	result= "x" .. string.format("%02d", tonumber(frame.args[1]))
	return result
end

function p.test2(frame)
	local k = ''
	k = mw.ustring.match(frame.args[1],'(.-)[ :.,!?;)”“…«»<].*')
	if mw.ustring.sub(k, -1) == '’' then
		k = mw.ustring.match(frame.args[1],'(.-)’')
	end
	return k
end
return p