Module:InfoboxEpisodeManga

local p = {} local episodesManga = mw.loadData( 'Module:Episodes/mangaData' ) local infoboxCreateDataItem = function (label, data) return ' ' end

function p.infoboxEpisodeManga(frame) local args = frame:getParent.args local argEp = args['episode'] or '0A' local epVal = episodesManga[argEp] local months = {[1] = 'January', [2] = 'February', [3] = 'March', [4] = 'April', [5] = 'May', [6] = 'June', [7] = 'July', [8] = 'August', [9] = 'September', [10] = 'October', [11] = 'November', [12] = 'December'} local epFullRel = '' if epVal['full release'] == nil then local dateY, dateM, dateD = epVal['release date']:match('([0-9]*)-([0-9]*)-([0-9]*)') local epRelDate = months[ tonumber(dateM) ] .. ' ' .. tonumber(dateD) .. ', ' .. dateY local epMagName, epMagIssue, epMagYear = epVal['magazine']:match('([AHY]*) #([^,]*), (.*)') epMagName = ({['AH'] = Animal House, ['YA'] = Young Animal})[epMagName] local epMagInfo = epMagName .. ' #' .. epMagIssue .. ' (' .. epMagYear .. ')' epFullRel = epMagInfo .. ' ' .. epRelDate else epFullRel = epVal['full release'] end local epEngName, epJapName, epRomName = , , '' if epVal['ename'] then epEngName = '&ldquo;' .. epVal['ename'] .. '&rdquo;' epEngName = epEngName ..    else epEngName =  end if epVal['jname'] then epJapName = ' ' .. epVal['jname'] end if epVal['rname'] then epRomName = ' ' .. epVal['rname'] end --       Try to match for previous and next episodes    -- local epCurr = argEp:match('0([A-P])') or argEp local epPrev = episodesManga[ '0' .. string.char( string.byte(epCurr) - 1 ) ] or       episodesManga[ tostring( (tonumber(argEp) or 1) - 1 ) ] or        '' -- No match found; empty string returned local epNext = episodesManga[ '0' .. string.char( string.byte(epCurr) + 1 ) ] or       episodesManga[ tostring( (tonumber(argEp) or -1) + 1 ) ] or        '' -- No match found; empty string returned if epPrev ~= '' then epPrev = '"" .. epPrev['ename'] .. '"' end if epNext ~= '' then epNext = '"" .. epNext['ename'] .. '"' end local infobox = { ' ',       '  ' .. epEngName .. epJapName .. epRomName .. ' ',        '  ' .. ( args['image'] or '' ) .. ' ',        ' ',        infoboxCreateDataItem( 'Volume', epVal['volume'] ), infoboxCreateDataItem( 'Episode', argEp ), infoboxCreateDataItem( 'Pages', ( args['pages'] or '' ) ), ' ',       infoboxCreateDataItem( 'Story arc', ( args['arc'] or '' ) ), infoboxCreateDataItem( 'Chapter', ( args['chapter'] or '' ) ), infoboxCreateDataItem( 'Release', epFullRel ), infoboxCreateDataItem( 'Previous', args['prev'] or epPrev ), infoboxCreateDataItem( 'Next', args['next'] or epNext ), ' '   }

local epTlRel = '' if epVal['full release'] == nil then epTlRel = '|magazine=' .. ( epVal['magazine'] or '' ) .. '\n|release date=' .. ( epVal['release date'] or '' ) else epTlRel = '|full release=' .. epVal['full release'] end local epTlPrev, epTlNext = ,  if args['prev'] == nil then epTlPrev = '' else epTlPrev = '|prev=' .. args['prev'] end if args['next'] == nil then epTlNext = '' else epTlNext = '|next=' .. args['next'] end local protoInfobox = { ''   }    return frame:preprocess( table.concat(protoInfobox, '\n') ) end

return p