242
55
24
24
24
444 https://galbaike.com/images/6/6d/GINKA_%E9%93%B6%E8%8A%B1_%E7%AB%8B%E7%BB%98.png;https://galbaike.com/images/6/6d/GINKA_%E9%93%B6%E8%8A%B1_%E7%AB%8B%E7%BB%98.png GINKA_银花_立绘.png
local p = {}
-- 换行处理 {{#invoke:角色卡片|newline|变量=xxx}}
function p.newline(frame)
local args = frame.args
local paragraphs = {}
local text = args['变量']
for line in text:gmatch("[^\r\n]*[\r\n]?") do
if line ~= "" then
table.insert(paragraphs, "<p>" .. line .. "</p>")
else
table.insert(paragraphs, "444") -- 插入单独的换行符
end
end
return table.concat(paragraphs, "\n")
end
-- 角色卡片图片处理
function p.kp_img(frame)
local args = frame.args
local data = args['img']
local sub = args['sub']
local text = ""
local dataArray = {}
for item in data:gmatch("[^;]+") do
-- 将拆分出的数据添加到text
local abc = frame:callParserFunction('filepath:'..item)
text = text .. abc .. ";"
table.insert(dataArray, item)
end
-- 删除最后一个;号
text = string.sub(text, 1, -2)
if sub == nil then
return text
else
local ss = tonumber(sub)
return dataArray[ss]
end
end
-- 解析以=分割的信息
function p.jskp(frame)
local args = frame.args
local input = args['变量']
local parsed_data = ''
for line in input:gmatch("[^\r\n]+") do
local key, value = line:match("(.*)=(.*)")
if key and value then
--print(key, "=", value)
parsed_data = parsed_data..'<p><strong>'..key.."</strong>:"..value..'</p>'
end
end
return parsed_data
end
return p