Module:Listify

From A Wiki of Ice and Fire
Revision as of 17:18, 13 September 2018 by Abjiklam (talk | contribs) (Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} function p.listify(frame) local args = getArgs(frame) local str = args[1] or "" str:gsub("<(br|B...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.listify(frame)
    local args = getArgs(frame)
    local str = args[1] or ""
    str:gsub("<(br|BR)%s*/*>", "\n")
    
    local l = mw.html.create('ul')
    for s in str:gmatch("([^" .. "\n" .. "]+") do
        l:tag('li'):wikitext(s)
    end
    return tostring(l)
end

return p