편집 요약 없음 |
편집 요약 없음 |
||
84번째 줄: | 84번째 줄: | ||
local hanja_header = '' | local hanja_header = '' | ||
-- hanja(漢) | -- hanja(漢) | ||
local hanja | local hanja, description = args[1], arg[2] | ||
local link = createlink({ | local link = createlink({ | ||
105번째 줄: | 95번째 줄: | ||
hanja_info_header:addCharacter(link) | hanja_info_header:addCharacter(link) | ||
hanja_info_header:addDescription( | hanja_info_header:addDescription(description) | ||
return '<span class="hanja-mean-sound">' .. hanja_info_header:done() .. '</span>' | return '<span class="hanja-mean-sound">' .. hanja_info_header:done() .. '</span>' |
2024년 5월 10일 (금) 03:01 판
local p = {}
local mw = mw
local createlink = require('Module:linkwithtemplate').test
---return 'U+ABCD'
---@param str string
---@return string
local function tounicode(str)
return 'U+' .. string.format('%x', mw.ustring.codepoint(str)):upper()
end
local hanja_info_header = {
html = mw.html.create('p'):addClass('hanja-info-header hanja-mean-sound')
}
hanja_info_header.hanja = hanja_info_header.html:tag('span'):addClass('hanja')
hanja_info_header.description = hanja_info_header.html:tag('span'):addClass('description')
---
---@param char string
function hanja_info_header:addCharacter(char)
self.hanja:wikitext(char)
end
---
---@param char string
function hanja_info_header:addDescription(char)
self.description:wikitext(char)
end
function hanja_info_header:done()
return tostring(self.html:done())
end
---comment
---@param mode string
---@param data table
---@param frame table
---@return string
---@return boolean isStandalone
function p.mean_sound(mode, data, frame)
local isStandalone;
if mode == '한자' then
isStandalone = true
hanja_info_header.html:addClass('onlyhanja')
hanja_info_header:addCharacter('[[' .. data.char .. ']]')
elseif mode == '신자체' then
isStandalone = true
hanja_info_header.html:addClass('onlyhanja')
hanja_info_header:addCharacter(frame:preprocess { text = '{{일본어=|[[' .. data.char .. ']]}}' })
elseif mode == "간체자" then
isStandalone = true
hanja_info_header.html:addClass('onlyhanja')
hanja_info_header:addCharacter(frame:preprocess { text = '{{중국어=|[[' .. data.char .. ']]}}' })
end
if mode == '훈음' then
isStandalone = false
hanja_info_header:addCharacter('[[' .. data.char .. ']]')
hanja_info_header:addDescription(data.mean_sound)
elseif mode == "중국어" then
isStandalone = false
hanja_info_header:addCharacter(frame:preprocess { text = '{{중국어=|[[' .. data.char .. ']]}}' })
hanja_info_header:addDescription(data.mean_sound)
else
isStandalone = false
hanja_info_header:addCharacter('[[' .. data.char .. ']]')
hanja_info_header:addDescription(data.mean_sound)
end
return hanja_info_header:done(), isStandalone
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
local hanja_header = ''
-- hanja(漢)
local hanja, description = args[1], arg[2]
local link = createlink({
[1] = '시리즈:리브레_한자사전/' .. (mw.ustring.codepoint(hanja) > 65535 and tounicode(hanja) or hanja),
[2] = hanja,
['템플릿'] = '리브레 위키:템플릿/한자',
['editintro'] = '리브레 위키:템플릿/한자/editintro',
})
hanja_info_header:addCharacter(link)
hanja_info_header:addDescription(description)
return '<span class="hanja-mean-sound">' .. hanja_info_header:done() .. '</span>'
end
return p