跳转到内容

模組:Vgname/sandbox

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

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

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, _ = content:find(pattern)
	if s then
		return content:sub(1, s-1), content:sub(s)
	end
	
	return content, ''
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 function main(args)
	local title, refs
	
	title, refs = refSplitter(args[1] or mw.title.getCurrentTitle())
	title = bold(args, title)
	
	if args.bracket == 'q' then
		title = '「' .. title .. '」'
	elseif yesno(args.bracket) == false then
		-- Nothing to do.
	else
		title = '《' .. title .. '》'
	end
	
	return title .. refs
end

local function original(args)
	--[[
	1. 找到需要标示的原文名
	2. 标记不转换标签
	3. 标记语言标签和斜体
	4. 标记语言tag
	--]]
	
end

local p = {}

function p.vgname(frame)
	local args = getArgs(frame)
	return p._vgname(args)
end

function p._vgname(args)
	return main(args)
end

return p