Title: Module:Hatnote list - freem URL Source: https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list Markdown Content: [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#) - [x] * [Home](https://freemwiki.com/wiki/Main_Page) * [Random](https://freemwiki.com/wiki/Special:Random) * [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AHatnote+list&returntoquery=mobileaction%3Dtoggle_view_mobile) * [Settings](https://freemwiki.com/index.php?title=Special:MobileOptions&returnto=Module%3AHatnote+list) * [About](https://freemwiki.com/wiki/About) * [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service) [freem](https://freemwiki.com/wiki/Main_Page) Search # Module:Hatnote list * [Language](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list "Language") * [Watch](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AHatnote+list) * [Edit](https://freemwiki.com/index.php?title=Module:Hatnote_list&action=edit) _Documentation for this module may be created at [Module:Hatnote list/doc](https://freemwiki.com/index.php?title=Module:Hatnote\_list/doc&action=edit&redlink=1 "Module:Hatnote list/doc (page does not exist)")_ [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-1)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-2)-- Module:Hatnote list --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-3)-- --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-4)-- This module produces and formats lists for use in hatnotes. In particular, --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-5)-- it implements the for-see list, i.e. lists of "For X, see Y" statements, --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-6)-- as used in {{about}}, {{redirect}}, and their variants. Also introduced --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-7)-- are andList & orList helpers for formatting lists with those conjunctions. --[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-8)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-9)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-10)local mArguments --initialize lazily[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-11)local mFormatLink = require('Module:Format link')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-12)local mHatnote = require('Module:Hatnote')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-13)local libraryUtil = require('libraryUtil')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-14)local checkType = libraryUtil.checkType[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-15)local p = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-16)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-17)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-18)-- List stringification helper functions[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-19)--[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-20)-- These functions are used for stringifying lists, usually page lists inside[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-21)-- the "Y" portion of "For X, see Y" for-see items.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-22)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-23)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-24)--default options table used across the list stringification functions[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-25)local stringifyListDefaultOptions = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-26)conjunction = "and",[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-27)separator = ",",[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-28)altSeparator = ";",[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-29)space = " ",[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-30)formatted = false[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-31)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-32)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-33)--Searches display text only[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-34)local function searchDisp(haystack, needle)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-35)return string.find([](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-36)string.sub(haystack, (string.find(haystack, '|') or 0) + 1), needle[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-37))[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-38)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-39)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-40)-- Stringifies a list generically; probably shouldn't be used directly[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-41)local function stringifyList(list, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-42)-- Type-checks, defaults, and a shortcut[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-43)checkType("stringifyList", 1, list, "table")[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-44)if #list == 0 then return nil end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-45)checkType("stringifyList", 2, options, "table", true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-46)options = options or {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-47)for k, v in pairs(stringifyListDefaultOptions) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-48)if options[k] == nil then options[k] = v end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-49)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-50)local s = options.space[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-51)-- Format the list if requested[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-52)if options.formatted then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-53)list = mFormatLink.formatPages([](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-54){categorizeMissing = mHatnote.missingTargetCat}, list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-55))[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-56)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-57)-- Set the separator; if any item contains it, use the alternate separator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-58)local separator = options.separator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-59)for k, v in pairs(list) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-60)if searchDisp(v, separator) then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-61)separator = options.altSeparator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-62)break[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-63)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-64)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-65)-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-66)local conjunction = s .. options.conjunction .. s[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-67)if #list == 2 and searchDisp(list[1], "§") or #list > 2 then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-68)conjunction = separator .. conjunction[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-69)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-70)-- Return the formatted string[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-71)return mw.text.listToText(list, separator .. s, conjunction)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-72)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-73)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-74)--DRY function[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-75)function p.conjList (conj, list, fmt)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-76)return stringifyList(list, {conjunction = conj, formatted = fmt})[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-77)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-78)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-79)-- Stringifies lists with "and" or "or"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-80)function p.andList (...) return p.conjList("and", ...) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-81)function p.orList (...) return p.conjList("or", ...) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-82)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-83)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-84)-- For see[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-85)--[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-86)-- Makes a "For X, see [[Y]]." list from raw parameters. Intended for the[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-87)-- {{about}} and {{redirect}} templates and their variants.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-88)--------------------------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-89)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-90)--default options table used across the forSee family of functions[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-91)local forSeeDefaultOptions = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-92)andKeyword = 'and',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-93)title = mw.title.getCurrentTitle().text,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-94)otherText = 'other uses',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-95)forSeeForm = 'For %s, see %s.',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-96)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-97)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-98)--Collapses duplicate punctuation at end of string, ignoring italics and links[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-99)local function punctuationCollapse (text)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-100) return text:match("[.?!]('?)%1(%]?)%2%.$") and text:sub(1, -2) or text[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-101)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-102)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-103)-- Structures arguments into a table for stringification, & options[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-104)function p.forSeeArgsToTable (args, from, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-105)-- Type-checks and defaults[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-106)checkType("forSeeArgsToTable", 1, args, 'table')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-107)checkType("forSeeArgsToTable", 2, from, 'number', true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-108)from = from or 1[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-109)checkType("forSeeArgsToTable", 3, options, 'table', true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-110)options = options or {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-111)for k, v in pairs(forSeeDefaultOptions) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-112)if options[k] == nil then options[k] = v end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-113)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-114)-- maxArg's gotten manually because getArgs() and table.maxn aren't friends[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-115)local maxArg = 0[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-116)for k, v in pairs(args) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-117)if type(k) == 'number' and k > maxArg then maxArg = k end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-118)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-119)-- Structure the data out from the parameter list:[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-120)-- * forTable is the wrapper table, with forRow rows[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-121)-- * Rows are tables of a "use" string & a "pages" table of pagename strings[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-122)-- * Blanks are left empty for defaulting elsewhere, but can terminate list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-123)local forTable = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-124)local i = from[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-125)local terminated = false[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-126)-- If there is extra text, and no arguments are given, give nil value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-127)-- to not produce default of "For other uses, see foo (disambiguation)"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-128)if options.extratext and i > maxArg then return nil end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-129)-- Loop to generate rows[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-130)repeat[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-131)-- New empty row[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-132)local forRow = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-133)-- On blank use, assume list's ended & break at end of this loop[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-134)forRow.use = args[i][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-135)if not args[i] then terminated = true end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-136)-- New empty list of pages[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-137)forRow.pages = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-138)-- Insert first pages item if present[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-139)table.insert(forRow.pages, args[i + 1])[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-140)-- If the param after next is "and", do inner loop to collect params[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-141)-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-142)while args[i + 2] == options.andKeyword do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-143)if args[i + 3] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-144)table.insert(forRow.pages, args[i + 3])[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-145)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-146)-- Increment to next "and"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-147)i = i + 2[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-148)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-149)-- Increment to next use[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-150)i = i + 2[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-151)-- Append the row[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-152)table.insert(forTable, forRow)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-153)until terminated or i > maxArg[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-154)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-155)return forTable[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-156)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-157)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-158)-- Stringifies a table as formatted by forSeeArgsToTable[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-159)function p.forSeeTableToString (forSeeTable, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-160)-- Type-checks and defaults[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-161)checkType("forSeeTableToString", 1, forSeeTable, "table", true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-162)checkType("forSeeTableToString", 2, options, "table", true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-163)options = options or {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-164)for k, v in pairs(forSeeDefaultOptions) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-165)if options[k] == nil then options[k] = v end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-166)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-167)-- Stringify each for-see item into a list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-168)local strList = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-169)if forSeeTable then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-170)for k, v in pairs(forSeeTable) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-171)local useStr = v.use or options.otherText[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-172)local pagesStr =[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-173)p.andList(v.pages, true) or[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-174)mFormatLink._formatLink{[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-175)categorizeMissing = mHatnote.missingTargetCat,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-176)link = mHatnote.disambiguate(options.title)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-177)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-178)local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-179)forSeeStr = punctuationCollapse(forSeeStr)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-180)table.insert(strList, forSeeStr)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-181)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-182)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-183)if options.extratext then table.insert(strList, punctuationCollapse(options.extratext..'.')) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-184)-- Return the concatenated list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-185)return table.concat(strList, ' ')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-186)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-187)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-188)-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-189)-- but not blank/whitespace values. Ignores named args and args < "from".[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-190)function p._forSee (args, from, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-191)local forSeeTable = p.forSeeArgsToTable(args, from, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-192)return p.forSeeTableToString(forSeeTable, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-193)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-194)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-195)-- As _forSee, but uses the frame.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-196)function p.forSee (frame, from, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-197)mArguments = require('Module:Arguments')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-198)return p._forSee(mArguments.getArgs(frame), from, options)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-199)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-200)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AHatnote_list#L-201)return p Retrieved from "[https://freemwiki.com/index.php?title=Module:Hatnote_list&oldid=579772](https://freemwiki.com/index.php?title=Module:Hatnote_list&oldid=579772)" [Last edited on 21 October 2025, at 06:18](https://freemwiki.com/index.php?title=Module:Hatnote_list&action=history) #### Languages This page is not available in other languages. freem * This page was last edited on 21 October 2025, at 06:18. * Content is available under [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/) unless otherwise noted. FreemWiki is operated by **FINGERPOWER DIGITAL TECHNOLOGY LLC** (Colorado, Entity ID 20221978727). * [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy) * [About](https://freemwiki.com/wiki/About) * [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service) * [Desktop](https://freemwiki.com/index.php?title=Module:Hatnote_list&mobileaction=toggle_view_desktop)