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

模块:Example:修订间差异

来自 LNN的:not(博客)?
DGCK81LNN留言 | 贡献
无编辑摘要
DGCK81LNN留言 | 贡献
无编辑摘要
 
(未显示同一用户的3个中间版本)
第3行: 第3行:
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs


function p._example(frame, code)
function p._example(frame, code, rh)
libraryUtil.checkType("_example", 1, frame, "table")
libraryUtil.checkType("_example", 1, frame, "table")
libraryUtil.checkType("_example", 2, code, "string")
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 source = mw.text.tag("pre", {}, mw.text.nowiki(code))
local result = frame:preprocess(code)
local result = frame:preprocess(code)
return source, result
if rh then
return source .. "\n\n" .. rh .. "\n\n" .. result
else
return source .. "\n\n" .. result
end
end
end


function p.example(frame)
function p.example(frame)
local args = getArgs(frame, { trim = false })
local args = getArgs(frame, { trim = false })
local str = args[1]
local str = args[1]
str = mw.text.unstripNoWiki(str)
str = mw.text.unstrip(str)
str = mw.text.killMarkers(str)
str = mw.text.decode(str)
str = mw.text.trim(str, "\n")
str = mw.text.trim(str, "\n")
return p._example(frame, str)
local rh = args.resultheader
 
return p._example(frame, str, rh)
end
end


return p
return p

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