Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 20:58, 5 June 2024 by genshin-impact>Mikevoir
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {}
local param = {
	rpStart = "rpStart",
	rpEnd = "rpEnd",
}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		parentFirst = true,
		wrappers = { 'Template:Rubi' },
	})
	return p._main(args)
end

function p._main(args)
	local ruby = mw.html.create('ruby')
	if args.large then ruby:addClass('rubi-large') end
	if args.center then ruby:addClass('rubi-center') end
	
	function mobileTag(ruby, text)
		if text then
			ruby:tag('rp')
				:wikitext(text)
				:done()
		end
	end
	
	for k, v in ipairs(args) do
		if k % 2 == 0 then
			mobileTag(ruby,args[param.rpStart])
			ruby:tag('rt'):wikitext(v)
			mobileTag(ruby,args[param.rpEnd])
		else
			ruby:wikitext(v)
		end
	end
	return ruby
end

return p