模組:Vgname/sandbox
外观
![]() | 这是Module:Vgname(差异)的沙盒。 参见本模块的测试样例(运行)。 |
请在 Module:Vgname/languages定义新的外语
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