Module:Cite

--[[ This module implements several standard formats for citations, used to specify various types of sources of information for articles such as lore, character descriptions, and quests.

For more information on MediaWiki's citation system, see this page: https://www.mediawiki.org/wiki/Help:Cite ]] local p = {} local utils = require("Module:Utils")

--[[ This is the base function for processing references. It is intended to be called from within more specific reference processing functions.

Parameters: • ref (reference structure): the processed information on the reference.

Structure format: • Reference structures: • name (string): the name of the reference; always required, will throw an error if      missing • group (optional, string): optional name for the reference group; ignored in subsequent uses of the reference • text (string): the text of the reference; required in first uses of a reference, useless for subsequent uses

Returns a string with formatted wikitext for the complete reference. ]] function p.base(ref) local result = {} local name = assert(ref.name, "Reference name not specified") local frame = mw.getCurrentFrame assert(ref.text, "Reference text not specified: " .. ref.name) local args = {name = name} if ref.group then args.group = ref.group end return frame:extensionTag("ref", ref.text, args) end

-- The entry point for Template:Cite dialogue. For more information, refer to the documentation for that template. function p.dialogue(f) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args end local dialogue_npc = assert(utils.get_arg_one_of(args, {1, 'character'}), "Character not specified") local ref = {} ref.name = "dialogue-" .. dialogue_npc ref.group = utils.get_arg(args, 'group') ref.text = "Dialogue with "		.. dialogue_npc		.. "" return p.base(ref) end

-- The entry point for Template:Cite lore. For more information, refer to the documentation for that template. function p.lore(f) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args end local lore_item = assert(utils.get_arg_one_of(args, {1, 'item'}), "Lore item not specified") local ref = {} ref.name = "lore-" .. lore_item ref.group = utils.get_arg(args, 'group') ref.text = "Text of the lore item " .. lore_item .. "" return p.base(ref) end

-- The entry point for Template:Cite quest. For more information, refer to the documentation for that template. function p.quest(f) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args end local quest_name = assert(utils.get_arg_one_of(args, {1, 'quest'}), "Quest not specified") local ref = {} ref.name = "quest-" .. quest_name ref.group = utils.get_arg(args, 'group') ref.text = "Events of the quest " .. quest_name .. "" return p.base(ref) end

return p