Module:Ingredient link list

local p = {} local f = mw.getCurrentFrame

function p.genlink(args) if args[1] == nil then return nil end local sep = args.sep or ';' local maxargs = (args.maxargs or #args)-1 local output_array = {} for i=1,maxargs,1 do		local name_pieces = {} for current_name in mw.text.gsplit(mw.text.trim(args[i]),sep) do			local trimmed_name = mw.text.trim(current_name) if trimmed_name ~= '' then name_pieces[trimmed_name] = true end end local converted_names = {} for name,exist in pairs(name_pieces) do			if exist then local prefix if string.find(name,'^Matching ') then prefix = 'Matching ' name=string.gsub(name,'^Matching ','') elseif string.find(name,'^Any ') then prefix = 'Any ' name=string.gsub(name,'^Any ','') else prefix = '' end table.insert(converted_names,f:preprocess(prefix....name..)) end end table.insert(output_array,table.concat(converted_names,' or ')) end return table.concat(output_array,' + ') end

function p.main local args = require('Module:ProcessArgs').merge(true) return p.genlink(args) end

return p