-- 模块:Trans
-- 作用:将输入字符串中的每个字符旋转180°显示,可选指定颜色
local p = {}
function p.main(frame)
local args = frame:getParent().args
local text = args[1] or ''
local color = mw.text.trim(args[2] or 'inherit')
local deg = mw.text.trim(args[3] or '180')
local output = {}
for uchar in string.gmatch(text, "[%z\1-\127\194-\244][\128-\191]*") do
table.insert(output, string.format('<span style="%s">%s</span>',
'display:inline-block;transform:rotate('.. deg ..'deg)',
mw.text.nowiki(uchar)
))
end
local colorStyle = ''
if color ~= '' then
colorStyle = string.format(' style="color:%s;"', color)
end
return string.format('<span%s>%s</span>', colorStyle, table.concat(output))
end
return p