模块:String2BulletedList

来自决策链云智库

可在模块:String2BulletedList/doc创建此模块的帮助文档

-- Module:StringSplit2BulletedList
local p = {}

function p.bulletedList(frame)
    -- Get the input string from the template
    local input = frame.args[1] or ''
    -- Get the prefix and suffix from the template
    local prefix = '{{Pcnodeoutput|'
    local suffix = '}}'

    -- Split the input string by space into a table
    local keywords = mw.text.split(input, ';%s*')

    -- Create the bulleted list from the table
    local list = mw.html.create('ul')
    for i, keyword in ipairs(keywords) do
        list:tag('li'):wikitext(prefix .. keyword .. suffix):done()
    end

    return tostring(list)
end

return p