Module:Formatted appearance is used to create a formatted style for first appearance and last appearance entries in Template:Infobox character or for other similar fictional elements.
The title of the major work the fictional element appeared in. Major works include TV series, films, books, albums and games. See WP:MAJORWORK.
optional
minor_work
The title of the minor work the fictional element appeared in. Minor works include TV episodes, chapters, songs and game missions. See WP:MINORWORK.
optional
issue
The number of the comic book issue the fictional element appeared in.
optional
date
The date of the publication/release of the minor work where the fictional element appeared in.
optional
-- This module requires the use of Module:List.locallist=require('Module:List')localp={}-- Local function which is used to get a correctly formatted entry.-- Function checks if the array had a value added by checking the counter,-- and returns the relevant result.localfunctiongetFormattedEntry(args,counter)if(counter==1)then-- Check if the counter stayed the same.return""-- Nothing was added to array; Return empty string.elseif(counter==2)then-- Check if only one value was added to the array.returnargs[1]-- Only one value was added to array; Return that value.else-- The array had more than one value added.returnlist.makeList("unbulleted",args)-- Call list.makeList() to retrieve the formatted plainlist.endend--[[Local function which is used to format an appearance for a comic book,in the style of: Line 1: <comic book title> #<issue number> (with comic book title in italics) Line 2: <release date>For other usages, see createGenericEntry().The function works with the following combinations: -- Only comic book title (example: "The Incredible Hulk"). -- Title and issue number (example: "The Incredible Hulk" and "181"). -- Title and release date (example: "The Incredible Hulk and "November 1974"). -- Title, issue number and release date (example: "The Incredible Hulk", "181" and "November 1974"). -- Only release date (example: "November 1974").--]]localfunctioncreateComicEntry(appearanceMajor,appearanceMinor,appearanceDate)localfullString={}-- Variable to save the array.localcounter=1-- Variable to save the array counter.if(appearanceMajor~=nil)then-- Check if a comic book title was entered.if(appearanceMinor==nil)then-- A comic book title was entered; Check if a issue number was entered.fullString[counter]=appearanceMajor-- A issue was not entered; Add only the comic book title to the array.counter=counter+1-- Increment counter by one.elsefullString[counter]=appearanceMajor.." "..appearanceMinor-- A issue was entered; Add both to the array.counter=counter+1-- Increment counter by one.endendif(appearanceDate~=nil)then-- Check if a release date was entered.fullString[counter]=appearanceDate-- A release date was entered; Add it to the array.counter=counter+1-- Increment counter by one.endreturngetFormattedEntry(fullString,counter)-- Call getFormattedEntry() to get a correctly formatted entry.end--[[Local function which is used to format an appearance for most usages,including television, film, books, songs and games, in the style of: Line 1: <minor work title> (in quotes) (Minor works include: TV episodes, chapters, songs and game missions) Line 2: <major work title> (in italics) (Major works include: TV series, films, books, albums and games) Line 3: <release date>For comic book usages, see createComicEntry().The function works with the following combinations: -- Only minor work title (example: "Live Together, Die Alone"). -- Minor work title and major work title (example: "Live Together, Die Alone" and "Lost"). -- Minor work title and release date (example: "Live Together, Die Alone" and "May 24, 2006"). -- Minor work title, major work title and release date (example: "Live Together, Die Alone", "Lost" and "May 24, 2006"). -- Only major work title (example: "Lost"). -- major work title and release date (example: "Lost" and "May 24, 2006"). -- Only release date (example: "May 24, 2006").--]]localfunctioncreateGenericEntry(appearanceMajor,appearanceMinor,appearanceDate)localfullString={}-- Variable to save the array.localcounter=1-- Variable to save the array counter.if(appearanceMinor~=nil)then-- Check if a minor appearance was entered.fullString[counter]=appearanceMinor-- A minor appearance was entered; Add it to the array.counter=counter+1-- Increment counter by one.endif(appearanceMajor~=nil)then-- Check if a major appearance was entered.fullString[counter]=appearanceMajor-- A major appearance was entered; Add it to the array.counter=counter+1-- Increment counter by one.endif(appearanceDate~=nil)then-- Check if a release date was entered.fullString[counter]=appearanceDate-- A release date was entered; Add it to the array.counter=counter+1-- Increment counter by one.endreturngetFormattedEntry(fullString,counter)-- Call getFormattedEntry() to get a correctly formatted entry.end-- Local function which is used to format with a hash symbol comic book issues.-- For other minor works, see getFormattedGenericMinorWork().localfunctiongetFormattedComicMinorWorkTitle(issue)if(issue~=nil)then-- Check if the issue is not nil.if(string.find(issue,"#"))then-- Check if the issue already has a hash symbol.returnissue-- Hash symbol already present; Return issue.elselocalformattedString=string.gsub(issue,"%d+","#%1")-- Hash symbol not found; Add the symbol before the issue number.returnformattedString-- Return issue.endelsereturnnil-- issue is nil; Return nil.endend-- Local function which is used to format with quotes a minor work title of most types.-- For comic book issues, see getFormattedComicMinorWork() (see [MOS:MINORWORK]).localfunctiongetFormattedGenericMinorWorkTitle(title)if(title~=nil)then-- Check if the title is not nil.return"\""..title.."\""-- Title is not nil; Add quotes to the title.elsereturnnil-- Title is nil; Return nil.endend-- Local function which is used to format with italics a major work title (see [MOS:MAJORWORK]).localfunctiongetFormattedMajorWorkTitle(title)if(title~=nil)then-- Check if the title is not nil.return"''"..title.."''"-- Title is not nil; Add italics to the title.elsereturnnil-- Title is nil; Return nil.endend-- Local function which does the actual main process.localfunction_getFormattedAppearance(args)localappearanceMajor=args['major_work']-- Get the title of the major work.localappearanceMinor=args['minor_work']-- Get the title of the minor work.localisComic=false-- Variable to save the status of wether the appearence is from a comic book.if(args['issue']~=nil)then-- Check if the comic specific issue is not nil. appearanceMinor=args['issue']-- Issue is not nil; Get the issue number.isComic=true-- Set isComic to true.endlocalappearanceDate=args['date']-- Get the release date of the minor work.localformattedAppearanceMajor=getFormattedMajorWorkTitle(appearanceMajor)-- Call getFormattedMajorWorkTitle() to get a formatted major work title.if(isComic==false)then-- Check if the appearance is a comic book appearance.-- The appearance is not a comic book appearance; localformattedAppearanceMinor=getFormattedGenericMinorWorkTitle(appearanceMinor)-- Call getFormattedGenericMinorWorkTitle() to get a formatted minor work title.returncreateGenericEntry(formattedAppearanceMajor,formattedAppearanceMinor,appearanceDate)-- Call createGenericEntry() to create an appearance entry.else-- The appearance is a comic book appearance. localformattedAppearanceMinor=getFormattedComicMinorWorkTitle(appearanceMinor)-- Call getFormattedComicMinorWorkTitle() to get a formatted minor work title.returncreateComicEntry(formattedAppearanceMajor,formattedAppearanceMinor,appearanceDate)-- Call createComicEntry() to create a comic book appearance entry.endend--[[Public function which is used to format the |first_appeared= and |last_appeared= fields.The usage of this module allows for correct title formatting (see [MOS:MAJORWORK] and [MOS:MINORWORK]),and correct line breaks based on guidelines (see [WP:UBLIST]).Parameters: -- |major_work= — optional; The title of the major work the fictional element appeared in. Major works include TV series, films, books, albums and games. -- |minor_work= — optional; The title of the minor work the fictional element appeared in. Minor works include TV episodes, chapters, songs and game missions. -- |issue= — optional; The number of the comic book issue the fictional element appeared in. -- |date= — optional; The date of the publication/release of the minor work where the fictional element appeared in.--]]functionp.getFormattedAppearance(frame)localgetArgs=require('Module:Arguments').getArgs;-- Use Module:Arguments to access module arguments.localargs=getArgs(frame);-- Get the arguments sent via the template.return_getFormattedAppearance(args)-- Call _getFormattedAppearance() to perform the actual process.endreturnp