跳转到内容

模組:Var

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2020年2月27日 (四) 15:52 建立内容为“local p={} local lib_arg={} --{{#invoke:沙盒/a2569875/Var|findNowiki}} function p.findNowiki(frame) local args, working_frame if frame == mw.…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

local p={}
local lib_arg={}
--{{#invoke:沙盒/a2569875/Var|findNowiki}}
function p.findNowiki(frame)
	local args, working_frame
    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end
        args = lib_arg.getArgs(frame, {
        	parentFirst=true,
        	trim = false,
			removeBlanks = false
        })
        working_frame = frame
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
        if type(args) ~= type({}) then args = {frame} end
    end
    local mark_name = mw.text.trim(args["1"] or args[1] or "")
    if mark_name == '' then return '' end
    local mark_get_mart = frame:extensionTag( mark_name, mark_name )
    if mw.ustring.find(mark_get_mart,'\127') then
    	local max_id = ''
    	mw.ustring.gsub(mark_get_mart, mark_name .. '%-([0-9A-Za-z]+)%-', function(id)max_id = id end)
    	return tonumber(max_id, 16)
    end
    return ''
end
return p