편집 요약 없음 |
편집 요약 없음 |
||
| 113번째 줄: | 113번째 줄: | ||
end | end | ||
end | end | ||
p. | p.unicodeBlock = require('Module:UnicodeBlock').unicodeBlock | ||
---------------------- {{유니코드문자}} -------------------------- | ---------------------- {{유니코드문자}} -------------------------- | ||
---@param frame table | ---@param frame table | ||
| 119번째 줄: | 119번째 줄: | ||
function p.unicodechar(frame) | function p.unicodechar(frame) | ||
---@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 | ||
class = '' | class = '' | ||
else | else | ||
class = args['class'] | class = args['class'] or 'infobox' | ||
end | end | ||
local charname = args['이름'] or mw.title.getCurrentTitle().prefixedText | local charname = args['이름'] or mw.title.getCurrentTitle().prefixedText | ||
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. | local eng = args['영어이름'] or p.unicodeBlock(curr) | ||
local lang = args['lang'] or 'ko' | local lang = args['lang'] or 'ko' | ||
local prefix = args['경로'] or '' | local prefix = args['경로'] or '' | ||
local | local arrow = { | ||
prev = '<i class="fas fa-chevron-left unicodechar-arrow"></i></span>', | |||
next = '<i class="fas fa-chevron-right unicodechar-arrow"></i></span>' | |||
} | |||
local buildlink = require('Module:linkwithtemplate').test | |||
local function link(pagename, linktext, arrow, template, editintro) | |||
if template then | |||
return buildlink({ | |||
[1] = pagename, | |||
[2] = string.format('<div>%s<br>%s</div>', linktext, arrow), | |||
['템플릿'] = template, | |||
['editintro'] = editintro, | |||
}) | |||
else | |||
return ustring.format('[[%s|<div>%s<br>%s</div>]]', pagename, linktext, arrow or '') | |||
end | |||
end | |||
local htmlroot = mw.html.create('table') | local htmlroot = mw.html.create('table') | ||
| 162번째 줄: | 162번째 줄: | ||
end | end | ||
local | local prevlink, nextlink | ||
if curr == nil then | if curr == nil then | ||
return | return '<span class="warning">기호(문자)를 입력하지 않았습니다. |문자 = (문자)</span>' | ||
else | |||
if curr:find("[Uu]") then | |||
curr = p.tochar(curr) | |||
end | |||
local prevchar = args['이전'] or args['전문자']; | |||
local prevlinktext = args['전문자이름'] or args['이전이름'] or prevchar | |||
local nextchar = args['이후'] or args['후문자']; | |||
local nextlinktext = args['후문자이름'] or args['이후이름'] or nextchar | |||
--------------------- 이전 문자 | |||
if prevchar then | |||
prevlink = link(prevchar, prevlinktext, arrow.prev) | |||
local | --- 이전 문자 없으면 자동 계산 | ||
else | else | ||
local | local char = ustring.char(p.code(curr, 'r10', -1)) | ||
local | local pagename = prefix or '' | ||
if ustring.codepoint( | local linktext = prevlinktext or char | ||
if ustring.codepoint(char) > 65535 then -- 문서 이름 결정 | |||
pagename = p.code(curr, '16', -1) .. pagename; -- 문자 코드로 | |||
else | else | ||
pagename = char .. pagename; -- 문자로 | |||
end | end | ||
if args['템플릿'] | if args['템플릿'] and not mw.title.new(pagename).exists then -- 템플릿 있고 페이지 없음 | ||
prevlink = link(pagename, linktext, arrow.prev, args['템플릿'], args['editintro']) | |||
else | else | ||
prevlink = link(pagename, linktext, arrow.prev) | |||
end | end | ||
end | end | ||
if | ------------------- 다음 문자 | ||
if nextchar then | |||
nextlink = link(nextchar, nextlinktext, arrow.next) | |||
--- 이전 문자 없으면 자동 계산 | |||
else | else | ||
local | local char = ustring.char(p.code(curr, 'r10', 1)) | ||
local | local pagename = prefix or '' | ||
if ustring.codepoint( | local linktext = nextlinktext or char | ||
local nextcode = p.code(curr, '16', 1) | |||
if ustring.codepoint(char) > 65535 then | |||
local nextcode = p.code(curr, '16', 1); pagename = nextcode; | |||
else | else | ||
pagename = char; | |||
end | end | ||
if args['템플릿'] | if args['템플릿'] and not mw.title.new(pagename).exists then | ||
nextlink = link(pagename, linktext, arrow.next, args['템플릿'], args['editintro']) | |||
else | else | ||
nextlink = link(pagename, linktext, arrow.next) | |||
end | end | ||
end | end | ||
| 227번째 줄: | 219번째 줄: | ||
<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, | <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, tr) | ||
else | else | ||
tr = ustring.format([[%s | tr = ustring.format([[%s | ||
| 233번째 줄: | 225번째 줄: | ||
<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>]], tr, lang, | <td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]], tr, lang, prevlink, lang, curr, p.code(curr), lang, nextlink) | ||
end | end | ||
return htmlroot:node(tr) | return htmlroot:node(tr) | ||