Module: Listify: Difference between revisions

From A Wiki of Ice and Fire
Jump to: navigation, search
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..."
 
Abjiklam (talk | contribs)
No edit summary
Line 9: Line 9:
      
      
     local l = mw.html.create('ul')
     local l = mw.html.create('ul')
     for s in str:gmatch("([^" .. "\n" .. "]+") do
     for s in str:gmatch("([^" .. "\n" .. "]+)") do
         l:tag('li'):wikitext(s)
         l:tag('li'):wikitext(s)
     end
     end

Revision as of 17:20, 13 September 2018

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