Moduł:Sandbox/Draco flavus/Test91
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Sandbox/Draco flavus/Test91/opis
local p = {}
local pag = require("mw.ustring")
function p.test_na_kreskeS(frame)
-- Wywołanie: {{#invoke: Sandbox/Draco flavus/Test9 | test_na_kreske | Indeks:Tajemniczy dom}}
-- Analizowany jest cały indeks starego typu.
-- Wynik: jeśli wśród 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 listastron = {}
local numerystron = {}
local liczbastron = 0
local p = ''
local q = ''
local ind = mw.title.new(frame.args[1]):getContent()
ind = ind:gsub('^.-Strony=','')
ind = ind:gsub('|Spis treści=.*$','')
for w in ind:gmatch ('%[%[Strona:[^]]*%]%]') do
table.insert(listastron, w:match('^%[%[(Strona:[^|]*)|'))
table.insert(numerystron, w:match('|([^]]*)%]%]$'))
liczbastron = liczbastron + 1
end
for i = 1, liczbastron - 1, 1 do
SubPageName = listastron[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=listastron[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 .. '!!!!!!!!!!!!!!!!!!!!!!' .. numerystron[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 .. numerystron[i] .. ' ' .. numerystron[i + 1] .. ' ' .. PageA .. ' ■ '.. PageB .. '<br>' .. ' {{pp|' .. p .. '|' .. q .. '}}<br>'
wynik1 = wynik1 .. 'python3.8 pwb.py replace -page:"' .. listastron[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:"' .. listastron[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