跳转到内容

模組:Vgname/sandbox

维基百科,自由的百科全书

这是本页的一个历史版本,由Lopullinen留言 | 贡献2018年6月20日 (三) 14:39编辑。这可能和当前版本存在着巨大的差异。

require('Module:No globals')

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')

local function refSplitter(content)
	local pattern = '\127\'"`UNIQ%-%-[Rr][Ee][Ff]%-%x+%-QINU`"\'\127' -- [[:en:WP:UNIQ]]
	
	local s, _ = str:find(pattern)
	if s then
		return str:sub(1, s-1), str:sub(s)
	end
	
	return str, ''
end

local function bold(args, content)
	local isBold = true
	
	if yesno(args.bold) ~= false then
		isBold = false
	end
	
	if isBold then
		content = '<b class="vgname-bold">' .. content .. '</b>'
	end
	
	return content
end

local p = {}

local function main(args)
	local title, refs
	
	if args[1] == nil then
		title = mw.title.getCurrentTitle()
	else
		title, refs = refSplitter(args[1])
	end
	
	title = bold(title)
	
	if args.bracket == 'q' then
		title = '「' .. title .. '」'
	elseif yesno(bracket) == false then
		-- Nothing to do.
	else
		title = '《' .. title .. '》'
	end
	
	return title .. refs
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	
end

return p