Module:ComicsInfobox

local Infobox = {} local HF = require("Module:ComicsHF") -- Since this should only be evaluated once per pageview, it's now global _G.vars = { Pagename = mw.title.getCurrentTitle.text }

-- -- Public functions -- --

function Infobox.CategoriesFromKeywords( fieldValue, valid, exceptions, vars ) local output = "" -- Field isn't blank if fieldValue ~= nil then -- Grab a valid pair and use it   for validKey, validValue in pairs(valid) do      -- If you find the validKey in the field, look more closely if string.find( string.lower(fieldValue), validKey ) ~= nil then -- Check if there are exceptions for the validKey if type(exceptions[validKey]) ~= "table" then -- There are no exceptions, just categorize using this validKey and move to the next validKey for valueKey, valueCategoryName in ipairs( validValue ) do           output = output .. HF.CategoryLink( valueCategoryName, vars.Pagename, "" ) end end end end end return output end

return Infobox