模块:换行处理:修订间差异
来自Gal中文百科
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第9行: | 第9行: | ||
image:attr('alt', 'Example Image') | image:attr('alt', 'Example Image') | ||
local encodedFileName = mw.text.encode("GINKA_银花_立绘.png") | local encodedFileName = mw.text.encode("GINKA_银花_立绘.png") | ||
return "[[Special:GINKA_银花_立绘.png|class=noviewer|link=]]" | return "[[Special:Redirect/file/GINKA_银花_立绘.png|class=noviewer|link=]]" | ||
end | end | ||
2024年4月17日 (三) 04:04的版本
class=noviewer|link= 脚本错误:函数“img”不存在。
local p = {}
function p.text(frame)
local args = frame.args
local title = require("mw.title")
local imageTitle = 'Example.jpg'
local image = mw.html.create('img')
image:attr('src', imageTitle)
image:attr('alt', 'Example Image')
local encodedFileName = mw.text.encode("GINKA_银花_立绘.png")
return "[[Special:Redirect/file/GINKA_银花_立绘.png|class=noviewer|link=]]"
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 getFilePath(fileName)
local title = require("mw.title")
-- 使用mw.title:new(fileName)创建一个标题对象
local fileTitle = title.new(fileName)
-- 使用getContent()获取文件内容
local content = fileTitle:getContent()
-- 如果获取到了内容,则返回文件路径
if content then
return content
else
return content
end
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