<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://159.13.49.45/index.php?action=history&amp;feed=atom&amp;title=Module%3AHatnote_list</id>
	<title>Module:Hatnote list - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://159.13.49.45/index.php?action=history&amp;feed=atom&amp;title=Module%3AHatnote_list"/>
	<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Hatnote_list&amp;action=history"/>
	<updated>2026-04-03T21:58:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>http://159.13.49.45/index.php?title=Module:Hatnote_list&amp;diff=369&amp;oldid=prev</id>
		<title>Nat: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Hatnote_list&amp;diff=369&amp;oldid=prev"/>
		<updated>2025-04-07T11:03:03Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:03, 7 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki:diff:1.41:old-368:rev-369 --&gt;
&lt;/table&gt;</summary>
		<author><name>Nat</name></author>
	</entry>
	<entry>
		<id>http://159.13.49.45/index.php?title=Module:Hatnote_list&amp;diff=368&amp;oldid=prev</id>
		<title>wikipedia&gt;Nihiltres: Updated from sandbox: added support for punctuation collapse when text is italicized. The update&#039;s content includes changes by users Johnuniq, Dexxor, and Nihiltres.</title>
		<link rel="alternate" type="text/html" href="http://159.13.49.45/index.php?title=Module:Hatnote_list&amp;diff=368&amp;oldid=prev"/>
		<updated>2023-11-13T21:00:31Z</updated>

		<summary type="html">&lt;p&gt;Updated from sandbox: added support for punctuation collapse when text is italicized. The update&amp;#039;s content includes changes by users Johnuniq, Dexxor, and Nihiltres.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--------------------------------------------------------------------------------&lt;br /&gt;
--                           Module:Hatnote list                              --&lt;br /&gt;
--                                                                            --&lt;br /&gt;
-- This module produces and formats lists for use in hatnotes. In particular, --&lt;br /&gt;
-- it implements the for-see list, i.e. lists of &amp;quot;For X, see Y&amp;quot; statements,   --&lt;br /&gt;
-- as used in {{about}}, {{redirect}}, and their variants. Also introduced    --&lt;br /&gt;
-- are andList &amp;amp; orList helpers for formatting lists with those conjunctions. --&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local mArguments --initialize lazily&lt;br /&gt;
local mFormatLink = require(&amp;#039;Module:Format link&amp;#039;)&lt;br /&gt;
local mHatnote = require(&amp;#039;Module:Hatnote&amp;#039;)&lt;br /&gt;
local libraryUtil = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- List stringification helper functions&lt;br /&gt;
--&lt;br /&gt;
-- These functions are used for stringifying lists, usually page lists inside&lt;br /&gt;
-- the &amp;quot;Y&amp;quot; portion of &amp;quot;For X, see Y&amp;quot; for-see items.&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--default options table used across the list stringification functions&lt;br /&gt;
local stringifyListDefaultOptions = {&lt;br /&gt;
	conjunction = &amp;quot;and&amp;quot;,&lt;br /&gt;
	separator = &amp;quot;,&amp;quot;,&lt;br /&gt;
	altSeparator = &amp;quot;;&amp;quot;,&lt;br /&gt;
	space = &amp;quot; &amp;quot;,&lt;br /&gt;
	formatted = false&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--Searches display text only&lt;br /&gt;
local function searchDisp(haystack, needle)&lt;br /&gt;
	return string.find(&lt;br /&gt;
		string.sub(haystack, (string.find(haystack, &amp;#039;|&amp;#039;) or 0) + 1), needle&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Stringifies a list generically; probably shouldn&amp;#039;t be used directly&lt;br /&gt;
local function stringifyList(list, options)&lt;br /&gt;
	-- Type-checks, defaults, and a shortcut&lt;br /&gt;
	checkType(&amp;quot;stringifyList&amp;quot;, 1, list, &amp;quot;table&amp;quot;)&lt;br /&gt;
	if #list == 0 then return nil end&lt;br /&gt;
	checkType(&amp;quot;stringifyList&amp;quot;, 2, options, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	for k, v in pairs(stringifyListDefaultOptions) do&lt;br /&gt;
		if options[k] == nil then options[k] = v end&lt;br /&gt;
	end&lt;br /&gt;
	local s = options.space&lt;br /&gt;
	-- Format the list if requested&lt;br /&gt;
	if options.formatted then&lt;br /&gt;
		list = mFormatLink.formatPages(&lt;br /&gt;
			{categorizeMissing = mHatnote.missingTargetCat}, list&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
	-- Set the separator; if any item contains it, use the alternate separator&lt;br /&gt;
	local separator = options.separator&lt;br /&gt;
	for k, v in pairs(list) do&lt;br /&gt;
		if searchDisp(v, separator) then&lt;br /&gt;
			separator = options.altSeparator&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Set the conjunction, apply Oxford comma, and force a comma if #1 has &amp;quot;§&amp;quot;&lt;br /&gt;
	local conjunction = s .. options.conjunction .. s&lt;br /&gt;
	if #list == 2 and searchDisp(list[1], &amp;quot;§&amp;quot;) or #list &amp;gt; 2 then&lt;br /&gt;
		conjunction = separator .. conjunction&lt;br /&gt;
	end&lt;br /&gt;
	-- Return the formatted string&lt;br /&gt;
	return mw.text.listToText(list, separator .. s, conjunction)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--DRY function&lt;br /&gt;
function p.conjList (conj, list, fmt)&lt;br /&gt;
	return stringifyList(list, {conjunction = conj, formatted = fmt})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Stringifies lists with &amp;quot;and&amp;quot; or &amp;quot;or&amp;quot;&lt;br /&gt;
function p.andList (...) return p.conjList(&amp;quot;and&amp;quot;, ...) end&lt;br /&gt;
function p.orList (...) return p.conjList(&amp;quot;or&amp;quot;, ...) end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- For see&lt;br /&gt;
--&lt;br /&gt;
-- Makes a &amp;quot;For X, see [[Y]].&amp;quot; list from raw parameters. Intended for the&lt;br /&gt;
-- {{about}} and {{redirect}} templates and their variants.&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--default options table used across the forSee family of functions&lt;br /&gt;
local forSeeDefaultOptions = {&lt;br /&gt;
	andKeyword = &amp;#039;and&amp;#039;,&lt;br /&gt;
	title = mw.title.getCurrentTitle().text,&lt;br /&gt;
	otherText = &amp;#039;other uses&amp;#039;,&lt;br /&gt;
	forSeeForm = &amp;#039;For %s, see %s.&amp;#039;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--Collapses duplicate punctuation at end of string, ignoring italics and links&lt;br /&gt;
local function punctuationCollapse (text)&lt;br /&gt;
 	return text:match(&amp;quot;[.?!](&amp;#039;?)%1(%]?)%2%.$&amp;quot;) and text:sub(1, -2) or text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Structures arguments into a table for stringification, &amp;amp; options&lt;br /&gt;
function p.forSeeArgsToTable (args, from, options)&lt;br /&gt;
	-- Type-checks and defaults&lt;br /&gt;
	checkType(&amp;quot;forSeeArgsToTable&amp;quot;, 1, args, &amp;#039;table&amp;#039;)&lt;br /&gt;
	checkType(&amp;quot;forSeeArgsToTable&amp;quot;, 2, from, &amp;#039;number&amp;#039;, true)&lt;br /&gt;
	from = from or 1&lt;br /&gt;
	checkType(&amp;quot;forSeeArgsToTable&amp;quot;, 3, options, &amp;#039;table&amp;#039;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	for k, v in pairs(forSeeDefaultOptions) do&lt;br /&gt;
		if options[k] == nil then options[k] = v end&lt;br /&gt;
	end&lt;br /&gt;
	-- maxArg&amp;#039;s gotten manually because getArgs() and table.maxn aren&amp;#039;t friends&lt;br /&gt;
	local maxArg = 0&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		if type(k) == &amp;#039;number&amp;#039; and k &amp;gt; maxArg then maxArg = k end&lt;br /&gt;
	end&lt;br /&gt;
	-- Structure the data out from the parameter list:&lt;br /&gt;
	-- * forTable is the wrapper table, with forRow rows&lt;br /&gt;
	-- * Rows are tables of a &amp;quot;use&amp;quot; string &amp;amp; a &amp;quot;pages&amp;quot; table of pagename strings&lt;br /&gt;
	-- * Blanks are left empty for defaulting elsewhere, but can terminate list&lt;br /&gt;
	local forTable = {}&lt;br /&gt;
	local i = from&lt;br /&gt;
	local terminated = false&lt;br /&gt;
	-- If there is extra text, and no arguments are given, give nil value&lt;br /&gt;
	-- to not produce default of &amp;quot;For other uses, see foo (disambiguation)&amp;quot;&lt;br /&gt;
	if options.extratext and i &amp;gt; maxArg then return nil end&lt;br /&gt;
	-- Loop to generate rows&lt;br /&gt;
	repeat&lt;br /&gt;
		-- New empty row&lt;br /&gt;
		local forRow = {}&lt;br /&gt;
		-- On blank use, assume list&amp;#039;s ended &amp;amp; break at end of this loop&lt;br /&gt;
		forRow.use = args[i]&lt;br /&gt;
		if not args[i] then terminated = true end&lt;br /&gt;
		-- New empty list of pages&lt;br /&gt;
		forRow.pages = {}&lt;br /&gt;
		-- Insert first pages item if present&lt;br /&gt;
		table.insert(forRow.pages, args[i + 1])&lt;br /&gt;
		-- If the param after next is &amp;quot;and&amp;quot;, do inner loop to collect params&lt;br /&gt;
		-- until the &amp;quot;and&amp;quot;&amp;#039;s stop. Blanks are ignored: &amp;quot;1|and||and|3&amp;quot; → {1, 3}&lt;br /&gt;
		while args[i + 2] == options.andKeyword do&lt;br /&gt;
			if args[i + 3] then&lt;br /&gt;
				table.insert(forRow.pages, args[i + 3])&lt;br /&gt;
			end&lt;br /&gt;
			-- Increment to next &amp;quot;and&amp;quot;&lt;br /&gt;
			i = i + 2&lt;br /&gt;
		end&lt;br /&gt;
		-- Increment to next use&lt;br /&gt;
		i = i + 2&lt;br /&gt;
		-- Append the row&lt;br /&gt;
		table.insert(forTable, forRow)&lt;br /&gt;
	until terminated or i &amp;gt; maxArg&lt;br /&gt;
&lt;br /&gt;
	return forTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Stringifies a table as formatted by forSeeArgsToTable&lt;br /&gt;
function p.forSeeTableToString (forSeeTable, options)&lt;br /&gt;
	-- Type-checks and defaults&lt;br /&gt;
	checkType(&amp;quot;forSeeTableToString&amp;quot;, 1, forSeeTable, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	checkType(&amp;quot;forSeeTableToString&amp;quot;, 2, options, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	for k, v in pairs(forSeeDefaultOptions) do&lt;br /&gt;
		if options[k] == nil then options[k] = v end&lt;br /&gt;
	end&lt;br /&gt;
	-- Stringify each for-see item into a list&lt;br /&gt;
	local strList = {}&lt;br /&gt;
	if forSeeTable then&lt;br /&gt;
		for k, v in pairs(forSeeTable) do&lt;br /&gt;
			local useStr = v.use or options.otherText&lt;br /&gt;
			local pagesStr =&lt;br /&gt;
				p.andList(v.pages, true) or&lt;br /&gt;
				mFormatLink._formatLink{&lt;br /&gt;
					categorizeMissing = mHatnote.missingTargetCat,&lt;br /&gt;
					link = mHatnote.disambiguate(options.title)&lt;br /&gt;
				}&lt;br /&gt;
			local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)&lt;br /&gt;
			forSeeStr = punctuationCollapse(forSeeStr)&lt;br /&gt;
			table.insert(strList, forSeeStr)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if options.extratext then table.insert(strList, punctuationCollapse(options.extratext..&amp;#039;.&amp;#039;)) end&lt;br /&gt;
	-- Return the concatenated list&lt;br /&gt;
	return table.concat(strList, &amp;#039; &amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Produces a &amp;quot;For X, see [[Y]]&amp;quot; string from arguments. Expects index gaps&lt;br /&gt;
-- but not blank/whitespace values. Ignores named args and args &amp;lt; &amp;quot;from&amp;quot;.&lt;br /&gt;
function p._forSee (args, from, options)&lt;br /&gt;
	local forSeeTable = p.forSeeArgsToTable(args, from, options)&lt;br /&gt;
	return p.forSeeTableToString(forSeeTable, options)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- As _forSee, but uses the frame.&lt;br /&gt;
function p.forSee (frame, from, options)&lt;br /&gt;
	mArguments = require(&amp;#039;Module:Arguments&amp;#039;)&lt;br /&gt;
	return p._forSee(mArguments.getArgs(frame), from, options)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Nihiltres</name></author>
	</entry>
</feed>