Jump to content

Module:Sandbox

From Wikibooks, open books for an open world
local p = {}

function p.list(frame)
    local args = frame.args
    
    if mw.ustring.match( args[1], "%s*%*" ) then
        return "Found list:\n\n" .. args[1]
    elseif mw.ustring.match( args[1], "UNIQ" ) then
        local links = mw.text.unstrip( args[1] ):gmatch( '<a href="[^"]*" title="[^"]*">(.-)</a>' )
        local link = {}
        
        for l in links do
            table.insert( link, table.concat({ '* [[', l, ']]' }) )
        end
        
        return table.concat(link, '\n')
    else
        return mw.text.nowiki( args[1] ):gsub( '[ \n]', { [' ']='&nbsp;', ['\n']='<br/>' } );
    end
end

return p