Module:ChapterVariables
Jump to navigation
Jump to search
Documentation for this module may be created at Module:ChapterVariables/doc
local p = {}
function p.main(frame)
local chapterVariablesText = frame.args[1]
local chapterVariablesData = ""
local chapterVariablesResult = ""
if frame.args[2] == nil then
chapterVariablesData = mw.loadData('Module:ChapterVariables/data')
else
chapterVariablesData = mw.loadData('Module:ChapterVariables/data/' .. frame.args[2])
end
if chapterVariablesData[chapterVariablesText] == nil then
if frame.args[2] == nil then
local magazineVariablesData = mw.loadData('Module:MagazineVariables/data')
else
local magazineVariablesData = mw.loadData('Module:MagazineVariables/data/' .. frame.args[2])
end
if magazineVariablesData then
chapterVariablesData = magazineVariablesData
end
end
if frame.args[2] == 'ja' then
chapterVariablesResult = frame:preprocess(chapterVariablesData[chapterVariablesText])
else
chapterVariablesResult = chapterVariablesData[chapterVariablesText]
end
-- Special case for CDDH chapters
if string.find(chapterVariablesText, "CDDH Chapter") then
local chapterNumber = string.match(chapterVariablesText, "%d+")
if chapterNumber and chapterNumber ~= "16" then
chapterVariablesResult = "Chapter " .. chapterNumber
end
end
return chapterVariablesResult or chapterVariablesText or ""
end
return p