FANDOM


local p = {}
local getArgs = require('Dev:Arguments').getArgs
 
local function html(strofy)
    local res = mw.html.create('div'):addClass('piosenka')
    for i,strofa in ipairs(strofy) do
        s = res:tag('div')
        if strofa.refren then
            s:addClass('piosenka_refren')
        else
            s:addClass('piosenka_zwrotka')
        end
        for j,wers in ipairs(strofa.wersy) do
            w = s:tag('div'):addClass('piosenka_wers')
            w:wikitext(wers[1])
 
            w:tag('span')
             :addClass('akordy')
             :wikitext('<span>'..table.concat(wers[2], '</span><span>')..'</span>')
        end
    end
    return res
end
 
function p.slowa(frame)
    local args = getArgs(frame, {
        valueFunc = function (key, value)
            if value then
    		    return mw.ustring.gsub(value, '^%s*(.-)%s*$', '%1')
    		end
	    end,
        removeBlanks = false,
        parentOnly = true
    })
    local strofy = {{refren=false, wersy={}}}
    local i = 1
    while args[i] do
        mw.log(i, args[i])
        if args[i] == '' then
            table.insert(strofy, {refren=false, wersy={}})
            mw.log('zwrotka')
        elseif args[i] == '#refren' then
            table.insert(strofy, {refren=true, wersy={}})
            mw.log('refren')
        else
            table.insert(strofy[#strofy].wersy, {mw.text.trim(args[i]), mw.text.split(args[i+1], ';')})
            i = i+1
        end
        i = i+1
    end
    for i=#strofy,1,-1 do
        if #strofy[i].wersy == 0 then
            table.remove(strofy, i)
        end
    end
    return html(strofy)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.