언라이트 ~unlight~ 위키
잔글편집 요약 없음
태그: sourceedit
잔글편집 요약 없음
태그: sourceedit
 
19번째 줄: 19번째 줄:
 
local imagePath = args[1]
 
local imagePath = args[1]
 
local imageAlt = args[2] and '|' .. args[2] or ''
 
local imageAlt = args[2] and '|' .. args[2] or ''
local isLinkedTo = args['링크'] and '|' .. args['링크'] or ''
+
local isLinkedTo = args['링크'] and '|링크=' .. args['링크'] or ''
 
local isPlainLink = args['타입'] == '링크'
 
local isPlainLink = args['타입'] == '링크'
 
local prefix = imagePath:match('^파일:') and '' or isPlainLink and ':파일:' or '파일:'
 
local prefix = imagePath:match('^파일:') and '' or isPlainLink and ':파일:' or '파일:'

2017년 2월 13일 (월) 07:10 기준 최신판

이 모듈에 대한 설명문서는 모듈:ImageLink/설명문서에서 만들 수 있습니다

------------------------------------------------------------
-- 이미지 링크 | Image Link
-- 
-- 예제.png 또는 파일:예제.png를 파일:예제.png 링크로 치환
-- 
-- @Author(s): User:Cafeinlove
-- @License: MIT License
------------------------------------------------------------

local imageLink = {}

local getArgs = getArgs or require('Module:Arguments').getArgs

function imageLink.main(frame)
    local args = getArgs(frame)
    
    if not args[1] then return '' end
    
    local imagePath = args[1]
    local imageAlt = args[2] and '|' .. args[2] or ''
    local isLinkedTo = args['링크'] and '|링크=' .. args['링크'] or ''
    local isPlainLink = args['타입'] == '링크'
    local prefix = imagePath:match('^파일:') and '' or isPlainLink and ':파일:' or '파일:'
    
    return '[[' .. prefix .. imagePath .. imageAlt .. isLinkedTo .. ']]'
end

return imageLink