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

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

来自Gal中文百科
Yexiaoyu留言 | 贡献
无编辑摘要
Yexiaoyu留言 | 贡献
无编辑摘要
第8行: 第8行:
     image:attr('src', imageTitle)
     image:attr('src', imageTitle)
     image:attr('alt', 'Example Image')
     image:attr('alt', 'Example Image')
     return frame:expandTemplate{ title = 'filepath', args = { '{{!}}' } }
     return mw.title:new("GINKA_银花_立绘.png"):getContent()
end
end



2024年4月17日 (三) 03:44的版本

mw.title.lua第392行Lua错误:bad argument #1 to 'title.new' (number or string expected, got table) 脚本错误:函数“img”不存在。


local p = {}

function p.text(frame)
    local args = frame.args

    local imageTitle = 'Example.jpg'
    local image = mw.html.create('img')
    image:attr('src', imageTitle)
    image:attr('alt', 'Example Image')
    return mw.title:new("GINKA_银花_立绘.png"):getContent()
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