打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:换行处理:修订间差异

来自Gal中文百科
Yexiaoyu留言 | 贡献
无编辑摘要
Yexiaoyu留言 | 贡献
无编辑摘要
第6行: 第6行:
     -- 检查参数是否为空
     -- 检查参数是否为空
     if variable then
     if variable then
         local newText = string.gsub(variable, "\n", "</p>")
         textToParagraphs(variable)
        newText = "<p>" .. newText
        -- 如果文本以换行符结尾,则添加一个闭合的</p>标签
    if string.sub(newText, -1) == "\n" then
        newText = newText .. "</p>"
    else
        newText = newText .. "</p>"
     end
     end
        return newText
end
     else
function textToParagraphs(text)
         return ''
    local paragraphs = {}
     for line in text:gmatch("[^\r\n]+") do
         table.insert(paragraphs, "<p>" .. line .. "</p>")
     end
     end
    return table.concat(paragraphs, "\n")
end
end
return p
return p

2024年4月3日 (三) 10:09的版本

脚本错误:函数“img”不存在。


local p = {}

function p.text(frame)
    local args = frame.args
    local variable = args['变量'] or ''
    -- 检查参数是否为空
    if variable then
        textToParagraphs(variable)
    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