모듈:Cite
이 모듈은 현재 정상 작동하지 않습니다. 사용하지 마세요.
| 이 모듈은 다음의 모듈에 의존합니다. |
이 모듈은 인용 틀 사용 시 확장 후 포함 크기(post-expand include size)의 한계로 더 이상의 틀을 추가할 수 없는 경우에 사용합니다. 너무 많은 틀을 사용한 경우가 아니라면 해당 모듈을 사용하지 마세요.
예제
[편집]{{#invoke:cite |<틀 이름>|<인용 틀 변수>}}
{{cite book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}- EB Green (1915). 《Title》. PseudoRandom.
{{#invoke:cite |book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}- 모듈:Citation/CS1 368번째 줄에서 Lua 오류: attempt to call upvalue 'is_set' (a nil value).
require ('strict');
local cfg = mw.loadData ('Module:Cite/config');
--[[--------------------------< S U B S T I T U T E >----------------------------------------------------------
<message>의 $1, $2 등을 <data_t>의 데이터로 대체합니다. <data_t>가 nil이 아니면 일반 텍스트로 대체된 문자열을 반환하고,
그렇지 않으면 <message>를 반환합니다.
]]
local function substitute (message, data_t)
return data_t and mw.message.newRawMessage (message, data_t):plain() or message;
end
--[[--------------------------< M A K E _ E R R O R _ M S G >--------------------------------------------------
모듈 이름, 메시지 텍스트, 도움말 링크 및 오류 범주를 사용하여 오류 메시지를 조합합니다.
]]
local function make_error_msg (frame, msg)
local module_name = frame:getTitle(); -- 접두사와 도움말 링크 레이블에 사용될 모듈 이름 가져오기
local namespace = mw.title.getCurrentTitle().namespace; -- 분류에 사용됨
local category_link = (0 == namespace) and substitute ('[[분류:$1]]', {cfg.settings_t.err_category}) or '';
return substitute ('<span style="color:#d33">오류: {{[[$1|#invoke:$2]]}}: $3 ([[:$4|$5]])</span>$6',
{
module_name, -- 네임스페이스가 있는 모듈 이름
module_name:gsub ('Module:', ''), -- 네임스페이스가 없는 모듈 이름
msg, -- 오류 메시지
cfg.settings_t.help_text_link, -- 도움말 페이지의 텍스트로 연결되는 위키링크
cfg.settings_t.help, -- 도움말 위키링크 표시 텍스트
category_link -- 오류 범주 링크 (주 네임스페이스 오류에만 해당)
})
end
--[[--------------------------< C I T E >---------------------------------------------------------------------
적절한 매개변수로 Module:Citation/CS1/sandbox를 호출하는 함수입니다. 문서가 post-expand include 크기 제한을 초과할 때 사용됩니다.
{{#invoke:cite|book|title=제목}}
]]
local function cite (frame, template)
local args_t = require ('Module:Arguments').getArgs (frame, {frameOnly=true});
template = template:lower(); -- 테이블 인덱스를 위해 소문자로 변경
if not cfg.known_templates_t[template] then -- 이 틀 이름을 인식하는가?
return make_error_msg (frame, substitute (cfg.settings_t.unknown_name, {template})); -- 아니요; 오류 메시지와 함께 중단
end
local config_t = {['CitationClass'] = cfg.citation_classes_t[template] or template}; -- CitationClass 값 설정
return require ('Module:Citation/CS1')._citation (nil, args_t, config_t); -- 인용 렌더링으로 이동
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
return setmetatable({}, {__index = -- 메타테이블에 __index가 설정된 빈 TABLE을 반환하여 주어진 KEY에 대해 다음을 반환합니다.
function(_, template) -- function(TABLE, KEY)로 호출되는 이 익명 함수
return function (frame) return cite (frame, template) end; -- 이 함수는 다시 KEY 이름을 사용하여 cite()를 호출하는 함수를 반환합니다.
end
})