Module:Chapters

require('Module:StrManip')

local p = {}

function p.main linkList = "" local vol = nil local ch = 0 local volSep = "" list = mw.getCurrentFrame.args[1] --list = "https://linkA55.zip[ch23] ,https://linkB{A note},https://linkC [vol3],https://linkD" local chapters = strSplit(list,",\n") for i,chapter in ipairs(chapters) do		local linkCh = chapter:match("(%d+)%.zip") local terms = chapter:match(" ?%[(.*)%]") local note = chapter:match(" ?%{(.*)%}")

chapter = chapter:gsub(" ?%[.*%]","") chapter = chapter:gsub(" ?%{.*%}","") --mw.logObject(terms) --if (linkCh) then			Ach = linkCh			Adec = chapter:match("%.%d+")		end -- if (terms) then Avol = terms:match("vol(%d+)") Ach = terms:match("ch(%d+)") Adec = terms:match("ch%d+(%.%d+)") AchapTitle = terms:gsub(" ?ch(%d+) ?",""):gsub(" ?vol(%d+) ?","") --mw.logObject(Avol) mw.logObject(Ach) mw.logObject(AchapTitle) end if (Avol) then vol = Avol volSep = "=== Volume " .. vol .. " === "			Avol = nil --mw.logObject(vol) end if (Ach) then ch = Ach Ach = nil else ch = ch + 1 end --mw.logObject("chapter " .. ch) if not (chapter:find("http")) then chapter = "https://" .. chapter end linkString = "" if (vol) then linkString = linkString .. "Volume " .. vol .. " "		end if not (ch == "0") then linkString = linkString .. "Chapter " .. ch		end if (Adec) then linkString = linkString .. Adec AchapTitle = AchapTitle:gsub(" ?" .. Adec .. " ?","") Adec = nil end if (AchapTitle) and not (AchapTitle == "") then if not (ch == "0") then linkString = linkString .." - " end linkString = linkString .. AchapTitle AchapTitle = nil end --mw.logObject(linkString) link = volSep .. "[" .. chapter .. " " .. linkString .."]" volSep = "" if (note) then link = link .. " | " .. note end mw.logObject(link) linkList = linkList .. link .. " "	end mw.logObject(linkList) return linkList end

return p