模块:换行处理:修订间差异
来自Gal中文百科
更多操作
无编辑摘要 标签:手工回退 |
无编辑摘要 |
||
| 第6行: | 第6行: | ||
-- 检查参数是否为空 | -- 检查参数是否为空 | ||
if variable then | if variable then | ||
local newText = string.gsub(variable, " | local newText = string.gsub(variable, "\n", "</p>") | ||
newText = "<p>" .. newText | newText = "<p>" .. newText | ||
-- 如果文本以换行符结尾,则添加一个闭合的</p>标签 | -- 如果文本以换行符结尾,则添加一个闭合的</p>标签 | ||
2024年4月3日 (三) 10:05的版本
242
55
24
脚本错误:函数“img”不存在。
local p = {}
function p.text(frame)
local args = frame.args
local variable = args['变量'] or ''
-- 检查参数是否为空
if variable then
local newText = string.gsub(variable, "\n", "</p>")
newText = "<p>" .. newText
-- 如果文本以换行符结尾,则添加一个闭合的</p>标签
if string.sub(newText, -1) == "\n" then
newText = newText .. "</p>"
end
return newText
else
return ''
end
end
return p