更多操作
242
55
24
24
24
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 if line == "\n" or line == "\r\n" then table.insert(paragraphs, "<br>") else table.insert(paragraphs, "<p>" .. line .. "</p>") end 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