Module:Term List

local p = {}

local Franchise = require("Module:Franchise") local Term = require("Module:Term") local utilsArg = require("Module:UtilsArg") local utilsString = require("Module:UtilsString")

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates["Term List"]) if err then return err.categoryText else local terms = p.termList(args.game, args.pages, args) return table.concat(terms, ", ") end end

function p.termList(game, pages, options) local terms = {} local rawTerms = {} for i, page in ipairs(pages) do		local pageEnd = string.find(page, "<") local additionalInfo = "" if pageEnd then additionalInfo = string.sub(page, pageEnd, #page) page = string.sub(page, 1, pageEnd - 1) if utilsString.endsWith(page, " ") then page = utilsString.trim(page) additionalInfo = " "..additionalInfo end end local pageInput = page page = mw.text.unstrip(page) if page ~= pageInput then additionalInfo = additionalInfo..string.gsub(pageInput, page, "") end terms[i] = Term.printTerm(page, game, options)..additionalInfo rawTerms[i] = Term.fetchTerm(page, game, options) or page end

return terms, rawTerms end

function p.Documentation return { termList = { params = {"game", "pages", "options"}, returns = { "A list the same size as  with Module:Term applied to each page.", "A list the same size as  with Module:Term applied to each page. The page name is returned as-is if it stores no terms.", },			cases = { {					desc = "Link's relatives", args = {"TWWHD", {"Link's Grandma", "Aryll (little sister) "}, { link = true }}, expect = { {							"Grandma", "Aryll (little sister) ", },						{"Grandma", "Aryll"}, },				},			}		}	} end

p.Templates = { ["Term List"] = { purpose = "Applies or  to a list of page names.", params = { [1] = {				name = "game", required = true, enum = Franchise.enum({ includeSeries = true }), type = "string", desc = "A game code.", nilIfEmpty= true, },			[2] = {				name = "pages", required = true, type = "content", desc = "Comma-separated list of wiki page names.", trim = true, nilIfEmpty= true, split = true, },			link = { type = "boolean", desc = "If present, the  option of  is applied.", },			plural = { type = "boolean", desc = "If present, is used instead of .", },		}	} }

return p