模块:Example:修订间差异
跳到导航
跳到搜索
小 (导入1个版本) |
小无编辑摘要 |
||
第11行: | 第11行: | ||
local result = frame:preprocess(code) | local result = frame:preprocess(code) | ||
if rh then | if rh then | ||
return source .. " | return source .. "\n" .. rh .. "\n" .. result | ||
else | else | ||
return source .. " | return source .. "\n" .. result | ||
end | end | ||
end | end |
2025年4月18日 (五) 14:11的最新版本
可在模块:Example/doc创建此模块的帮助文档
local p = {}
local libraryUtil = require("libraryUtil")
local getArgs = require("Module:Arguments").getArgs
function p._example(frame, code, rh)
libraryUtil.checkType("_example", 1, frame, "table")
libraryUtil.checkType("_example", 2, code, "string")
libraryUtil.checkType("_example", 3, rh, "string", --[[ nilOk= ]] true)
local source = mw.text.tag("pre", {}, mw.text.nowiki(code))
local result = frame:preprocess(code)
if rh then
return source .. "\n" .. rh .. "\n" .. result
else
return source .. "\n" .. result
end
end
function p.example(frame)
local args = getArgs(frame, { trim = false })
local str = args[1]
str = mw.text.unstrip(str)
str = mw.text.decode(str)
str = mw.text.trim(str, "\n")
local rh = args.resultheader
return p._example(frame, str, rh)
end
return p