此模块的文档可以在Module:虚拟歌手外语排行榜/doc创建

local p = {} --提供给模板
local f = {} --内部使用
local VocalistColors = require("模块:Vocalist_Colors")

function f.split(inputstr, sep)
    if sep == nil then
        sep = "%s"  -- 如果没有提供分隔符,则默认为空格
    else
        sep = mw.ustring.gsub(sep, '([%%%(%)%.%+%-%*%?%[%]%^%$])', '%%%1')  -- 转义分隔符中的特殊字符
    end

    local t = {}
    for str in mw.text.gsplit(inputstr, sep) do
        str = mw.ustring.gsub(str, '^%s*(.-)%s*$', '%1')  -- 去除前后空白
        if str ~= "" then  -- 只插入非空字符串
            table.insert(t, str)
        end
    end

    return t  -- 返回分割后的结果表
end

function p.color( frame )
    local vocals=f.split(frame.args[1], "、")
    local count = #vocals

    if count == 1 then
    	local color = VocalistColors.main({args = {vocals[1]}})
    	return color

    else
        local text = "linear-gradient("
        for i,v in pairs(vocals) do
        	local color = VocalistColors.main({args = {v}})
            text = text  .. color  .. " " .. (100 / count) * (i - 1) .. "%, "  .. color ..  " " .. (100 / count) * i .. "%, "
        end
        text = string.sub(text, 1, -3) .. ")"
        return text
    end
end

function p.author(frame)
	local authors = f.split(frame.args[1], "、")
	local text = ""
	for i,v in pairs(authors) do
		if mw.ustring.match(v, "[あ-んア-ン]") then
			text = text .. frame:preprocess( "{{lj|[[" ..v .. "]]}}") .. "、"	
		else
			text = text .. "[[" ..v .. "]]" .. "、" 
		end
	end
	text = mw.ustring.sub(text, 1, -2)
	return text
end

return p