본문으로 이동

모듈:R

위키낱말사전, 말과 글의 누리

이 설명 문서는 모듈:R/설명문서에서 편집할 수 있습니다.

하위 문서[편집]


local export = {}
-- 미디어위키 파서 도구 호출
local ugsub = mw.ustring.gsub
local umatch = mw.ustring.match
-- 형식 정의
function format_ref(langcode, identifier)
	local code = ugsub(langcode, "%[%[([^%]]+)%]%]", "%1") -- 자주 범하는 휴먼 에러#1: 틀에 위키링크를 넣으면 교정해 줍니다
	local id = ugsub(identifier, "%[%[([^%]]+)%]%]", "%1")
	code = ugsub(code, "^%w+:", "") -- 자주 범하는 휴먼 에러#2: 틀에 외부 위키 링크를 넣으면 교정해 줍니다.
	id   = ugsub(id, "^%w+:", "")
	
	res = {
        ["langcode"] = code,
        ["identifier"] = id
    }
	
	return res
end

function export.ref (frame)
	local params = {
		[1] = { required = true },
		[2] = { required = true },
		[3] = { alias_of = "p" }
	}
	
	local args = require("모듈:parameters").process(frame:getParent().args, params)
	
	local langcode = args[1]
	local identifier = args[2]
	
	return format_ref (langcode, identifier)
end

function export.show(frame)
	local args = frame:getParent().args
	
	local langcode = args[1]
	local identifier = args[2]

	local data = mw.loadData("모듈:R/data")
	
	local formatted_Ref = ugsub(langcode, "[%s_]+", "_")
	return "[[부록:참고문헌 자동 추가 리스트/" .. langcode .. "]]:" .. identifier
end

return export