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

模块:Example:修订间差异

来自 LNN的:not(博客)?
DGCK81LNN留言 | 贡献
无编辑摘要
DGCK81LNN留言 | 贡献
无编辑摘要
 
第11行: 第11行:
local result = frame:preprocess(code)
local result = frame:preprocess(code)
if rh then
if rh then
return source .. "\n" .. rh .. "\n" .. result
return source .. "\n\n" .. rh .. "\n\n" .. result
else
else
return source .. "\n" .. result
return source .. "\n\n" .. result
end
end
end
end

2023年2月26日 (日) 09:49的最新版本

此模块的文档可以在模块: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\n" .. rh .. "\n\n" .. result
	else
		return source .. "\n\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