模組: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, _ = 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