편집 요약 없음 |
편집 요약 없음 |
||
| 120번째 줄: | 120번째 줄: | ||
---@type table | ---@type table | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local class | local class | ||
if args['class'] == 'x' then | if args['class'] == 'x' then | ||
| 126번째 줄: | 127번째 줄: | ||
class = args['class'] or 'infobox' | class = args['class'] or 'infobox' | ||
end | end | ||
local curr = args[1] or args['기호'] or args['문자'] or nil | local curr = args[1] or args['기호'] or args['문자'] or nil | ||
local eng = args['영어이름'] or p.unicodeBlock(curr) | local eng = args['영어이름'] or p.unicodeBlock(curr) | ||
local lang = args['lang'] or 'ko' | local lang = args['lang'] or 'ko' | ||
local arrow = { | local arrow = { | ||
prev = '<i class="fas fa-chevron-left unicodechar-arrow"></i></span>', | prev = '<i class="fas fa-chevron-left unicodechar-arrow"></i></span>', next = '<i class="fas fa-chevron-right unicodechar-arrow"></i></span>' | ||
} | } | ||
local | local BuildLink = require('Module:linkwithtemplate').test | ||
local function link(pagename, linktext, | local function link(pagename, linktext, _arrow, template, editintro) | ||
if template then | if template then | ||
return | return BuildLink({ | ||
[1] = pagename, | [1] = pagename, | ||
[2] = string.format('<div>%s<br>%s</div>', linktext, arrow), | [2] = string.format('<div>%s<br>%s</div>', linktext, arrow), | ||
| 146번째 줄: | 144번째 줄: | ||
}) | }) | ||
else | else | ||
return ustring.format('[[%s|<div>%s<br>%s</div>]]', pagename, linktext, | return ustring.format('[[%s|<div>%s<br>%s</div>]]', pagename, linktext, _arrow or '') | ||
end | end | ||
end | |||
local htmlroot = mw.html.create('table') | local htmlroot = mw.html.create('table') | ||
| 155번째 줄: | 153번째 줄: | ||
:cssText('margin: 0 auto ;max-width: ;width: ;float: right; text-align: center; clear:right') | :cssText('margin: 0 auto ;max-width: ;width: ;float: right; text-align: center; clear:right') | ||
local | local charName, td | ||
if args['이름'] == '없음' then | if args['이름'] == '없음' then | ||
charName = ustring.format('<tr><th colspan="3"><small>%s</small></th></tr>', eng) | |||
else | else | ||
charName = ustring.format('<tr><th colspan="3"><div>%s</div><small>%s</small></th></tr>', args['이름'] or mw.title.getCurrentTitle().prefixedText, eng) | |||
end | end | ||
local prevlink, nextlink | local prevlink, nextlink | ||
if curr == nil then | if curr == nil then | ||
return '<span class="warning">기호(문자)를 입력하지 않았습니다. |문자 = (문자)</span>' | return '<span class="warning">기호(문자)를 입력하지 않았습니다. |문자 = (문자)</span>' | ||
| 169번째 줄: | 168번째 줄: | ||
curr = p.tochar(curr) | curr = p.tochar(curr) | ||
end | end | ||
--------------------- 이전 문자 | |||
local prevchar = args['이전'] or args['전문자']; | local prevchar = args['이전'] or args['전문자']; | ||
local prevlinktext = args['전문자이름'] or args['이전이름'] or prevchar | local prevlinktext = args['전문자이름'] or args['이전이름'] or prevchar | ||
if prevchar then | if prevchar then | ||
prevlink = link(prevchar, prevlinktext, arrow.prev) | prevlink = link(prevchar, prevlinktext, arrow.prev) | ||
| 179번째 줄: | 178번째 줄: | ||
else | else | ||
local char = ustring.char(p.code(curr, 'r10', -1)) | local char = ustring.char(p.code(curr, 'r10', -1)) | ||
local pagename | local pagename | ||
if ustring.codepoint(char) > 65535 then -- 문서 이름 결정 | if ustring.codepoint(char) > 65535 then -- 문서 이름 결정 | ||
pagename = | pagename = args['경로'] or '' .. p.code(curr, '16', -1); -- 문자 코드로 | ||
else | else | ||
pagename = | pagename = args['경로'] or '' .. char; -- 문자로 | ||
end | end | ||
prevlink = link(pagename, | prevlink = link(pagename, prevlinktext or char, arrow.prev, args['템플릿'], args['editintro']) | ||
end | end | ||
------------------- 다음 문자 | ------------------- 다음 문자 | ||
local nextchar = args['이후'] or args['후문자']; | |||
local nextlinktext = args['후문자이름'] or args['이후이름'] or nextchar | |||
if nextchar then | if nextchar then | ||
nextlink = link(nextchar, nextlinktext, arrow.next) | nextlink = link(nextchar, nextlinktext, arrow.next) | ||
| 195번째 줄: | 198번째 줄: | ||
else | else | ||
local char = ustring.char(p.code(curr, 'r10', 1)) | local char = ustring.char(p.code(curr, 'r10', 1)) | ||
local pagename | local pagename | ||
if ustring.codepoint(char) > 65535 then -- 문서 이름 결정 | if ustring.codepoint(char) > 65535 then -- 문서 이름 결정 | ||
pagename = | pagename = args['경로'] or '' .. p.code(curr, '16', 1); -- 문자 코드로 | ||
else | else | ||
pagename = | pagename = args['경로'] or '' .. char; -- 문자로 | ||
end | end | ||
nextlink = link(pagename, | nextlink = link(pagename, nextlinktext or char, arrow.next, args['템플릿'], args['editintro']) | ||
end | end | ||
end | end | ||
if args['순서반전'] then | if args['순서반전'] then | ||
charInfo = ustring.format([[ | |||
<td class='unicodechar-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td> | <td class='unicodechar-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td> | ||
<td class='unicodechar-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div> | <td class='unicodechar-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div> | ||
<div style="font-size:80%%; color: gray; ">%s</div></td> | <div style="font-size:80%%; color: gray; ">%s</div></td> | ||
<td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>%s]], lang, prevlink, lang, curr, p.code(curr), lang, nextlink, | <td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>%s]], lang, prevlink, lang, curr, p.code(curr), lang, nextlink, charName) | ||
else | else | ||
charInfo = ustring.format([[%s | |||
<td class='unicodechar-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td> | <td class='unicodechar-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td> | ||
<td class='unicodechar-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div> | <td class='unicodechar-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div> | ||
<div style="font-size:80%%; color: gray; ">%s</div></td> | <div style="font-size:80%%; color: gray; ">%s</div></td> | ||
<td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]], | <td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]], charName, lang, prevlink, lang, curr, p.code(curr), lang, nextlink) | ||
end | end | ||
return htmlroot:node( | return htmlroot:node(charInfo) | ||
end | end | ||
return p | return p | ||