연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는
/설명문서에 넣어주세요.
local p = {}
local html = mw.html
local title_ = mw.title
local ustring = mw.ustring
local getArgs = require('Module:Arguments').getArgs
---@param str string
---@return string 'U+ABCD'
local function unicode(str)
return 'U+' .. string.format('%x', ustring.codepoint(str)):upper()
end
-----------------------------------------------------------------------------------------------------
local function ThTd(th, td)
if td ~= '' then
local torender = html.create('tr')
torender:tag('th'):css('text-align', 'left'):wikitext(th)
torender:tag('td'):wikitext(td)
return torender
end
end
local function Th(th, class)
local render
if type(th) == 'table' then
render = '<tr><th colspan="2" class="%s" style="text-align: center">%s</th></tr>'
return render:format(class or '', tostring(th))
else
render = '<tr><th colspan="2" class="%s" style="text-align: center">%s</th></tr>'
return render:format(class or '', th)
end
end
local function Td(td, class)
local torender = html.create('tr')
if type(td) == 'table' then
render = '<tr><td colspan="2" class="%s" style="text-align: center">%s</td></tr>'
return render:format(class or '', tostring(td))
else
render = '<tr><td colspan="2" class="%s" style="text-align: center">%s</td></tr>'
return render:format(class or '', td)
end
return torender
end
-----------------------------------------------------------------------------------------
-- 메인 상자
function p:render()
local strokeOrder = require('Module:한자/획순').strokeOrder_
local unicodechar = require('모듈:unicode').unicodechar
local render = html.create('table'):addClass('hanja-info hanja hanja-alternativeform')
:cssText('box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%); border-radius: .25rem;background:rgb(255, 255, 255, 17%);')
render:node(Td(unicodechar({
['이름']='없음',
['class']='x',
['문자'] = self.trad['한자'],
['경로'] = '시리즈:리브레_한자사전/',
['템플릿']= '리브레 위키:템플릿/한자',
['editintro']= '리브레 위키:템플릿/한자/editintro'
})))
render:node(ThTd('뜻(訓)', self.trad['뜻']))
render:node(ThTd('소리(音)', self.trad['소리']))
render:node(ThTd('[[부수]]', '[[' .. self.trad['부수'] .. ']]'))
render:node(Td(strokeOrder(self.trad['획수'] .. '획', self.trad['한자'], '' )))
return render
end
function p.main(frame) return p:main_(frame) end
function p:main_(frame)
local args = getArgs(frame)
local css = args['css']
-- 변수 처리
args['한자'] = args['한자']
args['뜻'] = args['뜻'] or ' '
args['소리'] = args['소리'] or '-'
args['부수'] = args['부수'] or ' '
args['획수'] = args['획수'] or ' '
if args[1] == args['한자'] then
render:wikitext(mw.ustring.format('[[분류:%s|-]][[분류:한자/문자/기타|%s]]', args['부수'], args['소리']))
end
return self:render()
end
------------------------------------------------------------------------------------
return p