Module:TextC

Documentation for this module may be created at Module:TextC/doc

--[[ 
Replacement for textc template
]]
p = {}

Arg1 = mw.getCurrentFrame().args[1]
Arg2 = mw.getCurrentFrame().args[2]
Arg3 = mw.getCurrentFrame().args[3]

function p.SList()
    if (Arg1 == '' or Arg1 == nil) then
        return ''
    end
    if (Arg2 == '' or Arg2 == nil) then
        Arg2 = ';'
    end
    itemlist = mw.text.split(Arg1,Arg2,true)
    mainlist = mw.html.create( 'ul' )
    for k, item in pairs(itemlist) do
        ctag = mainlist:tag('li')
        ctag:wikitext(item)
    end
    mainlist = tostring(mainlist:allDone())
    return mainlist
end

function p.SListCol()
    if (Arg1 == '' or Arg1 == nil) then
        return 1
    end
    if (Arg2 == '' or Arg2 == nil) then
        Arg2 = ';'
    end
    itemlist = mw.text.split(Arg1,Arg2,true)
    if (#itemlist >= 3) then
        return 2
    else
        return 1
    end
end

function p.DelimRepl()
    if (Arg1 == '' or Arg1 == nil) then
        return ''
    end
    if (Arg2 == '' or Arg2 == nil) then
        Arg2 = ';'
    end
    if (Arg3 == '' or Arg3 == nil) then
        Arg3 = ' ♦'
    end
    delistr, x = string.gsub(Arg1, Arg2, Arg3)
    return string.format('%s %s',Arg3,delistr)
end

function p.Transp()
    if (Arg1 == '' or Arg1 == nil) then
        return ''
    end
    if (Arg2 == '' or Arg2 == nil) then
        Arg2 = ';'
    end
    itemlist = mw.text.split(Arg1,Arg2,true)
    mainlist = mw.html.create( 'ul' )
    argtbl = { 'npcAct' }
    for k, item in pairs(itemlist) do
        ctag = mainlist:tag('li')
        if (string.sub(item,1,1) ~= '-') then
            inm = string.format(':%s',item)
            tmpcall = mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl }
            ctag:wikitext(string.format('[[%s]] %s', item, tmpcall))
        else
            ctag:wikitext(string.sub(item,2))
        end
    end
    mainlist = tostring(mainlist:allDone())
    return mainlist
end

return p