2023年政策修订增补工作正在进行中,欢迎参与!
Module:Sandbox/D41D8CD98F/Lyrics
跳转到导航
跳转到搜索
local p = {}
local getArgs = require('Module:Arguments').getArgs
local lang = require('Module:Lang')
function p._lyrics(args)
local orig = mw.text.split(args.original or '', '\n')
local tran = mw.text.split(args.translated or '', '\n')
local llang = args.llang or 'ja'
local rlang = args.rlang or 'zh'
local lstyle = args.lstyle or ''
local rstyle = args.rstyle or ''
local containerstyle = args.containerstyle or ''
if args.original:match('<ruby') then
containerstyle = 'line-height:2.5;' .. containerstyle
end
local html = mw.html.create('div')
html
:addClass('Lyrics3')
:cssText(containerstyle)
for i=1,math.max(#orig, #tran) do
if orig[i] == '' and tran[i] == '' then
html:
tag('div')
:addClass('Lyrics3-line Lyrics3-empty-line')
:tag('br')
else
html:
tag('div')
:addClass('Lyrics3-line')
:tag('div')
:addClass('Lyrics3-original')
:cssText(lstyle)
:tag('div')
:node(lang.wrap(orig[i] or '', llang))
:done()
:done()
:tag('div')
:addClass('Lyrics3-translated')
:cssText(rstyle)
:tag('div')
:node(lang.wrap(tran[i] or '', rlang))
:done()
:done()
end
end
return tostring(html)
end
function p.lyrics(frame)
local args = getArgs(frame, {parentOnly = true})
return p._lyrics(args)
end
return p