更多操作
无编辑摘要 |
无编辑摘要 |
||
第16行: | 第16行: | ||
local data = args['img'] | local data = args['img'] | ||
local text = "" | local text = "" | ||
local dataArray = {} | |||
for item in data:gmatch("[^;]+") do | for item in data:gmatch("[^;]+") do | ||
-- 将拆分出的数据添加到text | -- 将拆分出的数据添加到text | ||
local abc = frame:callParserFunction('filepath:'..item) | local abc = frame:callParserFunction('filepath:'..item) | ||
text = text .. abc .. ";" | text = text .. abc .. ";" | ||
table.insert(dataArray, item) | |||
end | end | ||
-- 删除最后一个;号 | -- 删除最后一个;号 |
2024年4月17日 (三) 21:50的版本
242
55
24
24
24
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 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
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]+") do
table.insert(paragraphs, "<p>" .. line .. "</p>")
end
return table.concat(paragraphs, "\n")
--return textToParagraphs(args['变量'])
end
-- 角色卡片图片处理
function p.kp_img(frame)
local args = frame.args
local data = args['img']
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)
return text
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>'..key..":"..value..'</p>'
end
end
return parsed_data
end
function textToParagraphs(text)
local paragraphs = {}
for line in text:gmatch("[^\r\n]+") do
table.insert(paragraphs, "<p>" .. line .. "</p>")
end
return table.concat(paragraphs, "\n")
end
return p