잔글 Cerulean님이 모듈:디버그 문서를 넘겨주기를 만들지 않고 모듈:샌드박스 문서로 이동했습니다: 실험용 모듈
편집 요약 없음
1번째 줄: 1번째 줄:
local ustring = mw.ustring
local getArgs = require('Module:Arguments').getArgs
local p = {}
local p = {}


-------------------------  codepoint  ------------------------------------------
local ref = {
function p.code( data )
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
if type(data) == 'table' then
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
data = getArgs(frame)[1] or nil
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
elseif type(data) == 'string' then
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
return p.code_(char)
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
else
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
return '입력값이 없습니다.'
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
end
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'},
end
{['start'] = '0000', ['end'] = '007F', ['text'] = 'CJK Unified'}
function p.code_( char, base, offset )
}
if type(char) == 'string' then
tonumber('7DE', 16)
if offset == nil then offset = 0 end
local baseformat, head
if base == '10' then
baseformat = '%d'; head = 'U+'
elseif base == 'x16' then
baseformat = '%x'; head = 0
return ustring.codepoint(char) + offset
else
baseformat = '%x'; head = 'U+'
end
return head..ustring.upper(ustring.format(baseformat, ustring.codepoint(char) + offset))
else
return 0
end
end
----------------------  next codepoint  ---------------------------------------
function p.nextcode( data )
if type(data) == 'table' then char = getArgs(data)[1] or nil
else char = data or nil end if char then
return p.code_(char, '16', 1)
else
return '입력값이 없습니다.'
end
end
----------------------  prev codepoint  ---------------------------------------
function p.prevcode( data )
if type(data) == 'table' then char = getArgs(data)[1] or nil
else char = data or nil end
if char then
return p.code_(char, '16', -1)
else
return '입력값이 없습니다.'
end
end
----------------------  next char  ---------------------------------------
function p.nextchar( data )
local char
if type(data) == 'table' then char = getArgs(data)[1] or nil
else char = data or nil end
if char then
return ustring.char(p.code_(char, 'x16', 1))
else
return '입력값이 없습니다.'
end
end
----------------------  prev char  ---------------------------------------
function p.prevchar( data )
local char
if type(data) == 'table' then char = getArgs(data)[1] or nil
else char = data or nil end
if char then
return ustring.char(p.code_(char, 'x16', -1))
else
return '입력값이 없습니다.'
end
end
----------------------  {틀:유니코드문자}  ---------------------------------------
function p.unicodechar( frame )
local args = getArgs(frame)
local charname
if args['이름'] == nil then charname = mw.title.getCurrentTitle().prefixedText
else charname = args['이름'] end
local eng = args['영어이름'] or ''
local root = mw.html.create('table'):addClass('infobox'):cssText('margin:  ;max-width:  ;width:  ;float: right; text-align: center; clear:right')
local tr, td


if args['이름'] ~= '없음' then
function p.main(frame)
tr = ustring.format('<tr><th colspan="3"><div>%s</div><small>%s</small></th></tr>', charname, eng)
return ref[frame.args[1]]
else
tr = ustring.format('<tr><th colspan="3"><small>%s</small></th></tr>', eng)
end
root:node(tr)
 
    tr = mw.html.create('tr')
    local curr = args['기호'] or args['문자'] or ' '
    local prev, next
    if curr == ' ' then
return '<span class="warning">기호(문자)를 입력하지 않았습니다. |기호 = (기호)</span>'
else
    if ustring.codepoint(curr) > 65535 then
    prev = args['이전'] or args['전문자'] or '[['..p.prevcode(curr)..'|'..p.prevchar(curr)..']]'
    next = args['이후'] or args['후문자'] or '[['..p.nextcode(curr)..'|'..p.nextchar(curr)..']]'
    else
    prev = args['이전'] or args['전문자'] or '[['..p.prevchar(curr)..']]'
    next = args['이후'] or args['후문자'] or '[['..p.nextchar(curr)..']]'
    end
    end
td = ustring.format('<td style="width: 7em;font-size:1.2em;"><div>%s</div>←</td>', prev)
tr:node(td)
 
td = ustring.format('<td style="width: 4em"><div style="font-size: 1.8em;line-height: 1.2em;"><b>%s</b></div><small><span style="color: gray;">%s</span></small></td>', curr, p.code_(curr))
tr:node(td)
   
td = ustring.format('<td style="width: 7em;font-size:1.2em;"><div>%s</div>→</td>', next)
tr:node(td)
 
    root:node(tr)
return tostring(root)
end
end
return p
return p