https://grlucas.net/index.php?title=Module:Hatnote_list&feed=atom&action=history
Module:Hatnote list - Revision history
2024-03-28T18:56:35Z
Revision history for this page on the wiki
MediaWiki 1.39.0
https://grlucas.net/index.php?title=Module:Hatnote_list&diff=11432&oldid=prev
Grlucas: 1 revision imported
2020-07-23T20:23:24Z
<p>1 revision imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:23, 23 July 2020</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Grlucas
https://grlucas.net/index.php?title=Module:Hatnote_list&diff=11431&oldid=prev
en>Mr. Stradivarius: switch back to Module:Hatnote instead of Module:Hatnote/sandbox
2020-06-16T15:02:40Z
<p>switch back to <a href="/grl/Module:Hatnote" title="Module:Hatnote">Module:Hatnote</a> instead of <a href="/index.php?title=Module:Hatnote/sandbox&action=edit&redlink=1" class="new" title="Module:Hatnote/sandbox (page does not exist)">Module:Hatnote/sandbox</a></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:02, 16 June 2020</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l46">Line 46:</td>
<td colspan="2" class="diff-lineno">Line 46:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local separator = options.separator</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local separator = options.separator</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> --searches display text only</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> --searches display text only</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> function searchDisp(t, f)</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins style="font-weight: bold; text-decoration: none;">local </ins>function searchDisp(t, f)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return string.find(string.sub(t, (string.find(t, '|') or 0) + 1), f)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return string.find(string.sub(t, (string.find(t, '|') or 0) + 1), f)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l171">Line 171:</td>
<td colspan="2" class="diff-lineno">Line 171:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for k, v in pairs(forSeeTable) do</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for k, v in pairs(forSeeTable) do</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local useStr = v.use or options.otherText</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local useStr = v.use or options.otherText</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local pagesStr = p.andList(v.pages, true) or mHatnote._formatLink<del style="font-weight: bold; text-decoration: none;">(</del>mHatnote.disambiguate(options.title)<del style="font-weight: bold; text-decoration: none;">)</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local pagesStr = p.andList(v.pages, true) or mHatnote._formatLink<ins style="font-weight: bold; text-decoration: none;">{link = </ins>mHatnote.disambiguate(options.title)<ins style="font-weight: bold; text-decoration: none;">}</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> forSeeStr = punctuationCollapse(forSeeStr)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> forSeeStr = punctuationCollapse(forSeeStr)</div></td></tr>
</table>
en>Mr. Stradivarius
https://grlucas.net/index.php?title=Module:Hatnote_list&diff=395&oldid=prev
Grlucas: 1 revision imported
2018-12-16T22:25:18Z
<p>1 revision imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:25, 16 December 2018</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Grlucas
https://grlucas.net/index.php?title=Module:Hatnote_list&diff=394&oldid=prev
en>Galobtter: fix
2018-04-03T05:19:54Z
<p>fix</p>
<p><b>New page</b></p><div>--------------------------------------------------------------------------------<br />
-- Module:Hatnote list --<br />
-- --<br />
-- This module produces and formats lists for use in hatnotes. In particular, --<br />
-- it implements the for-see list, i.e. lists of "For X, see Y" statements, --<br />
-- as used in {{about}}, {{redirect}}, and their variants. Also introduced --<br />
-- are andList & orList helpers for formatting lists with those conjunctions. --<br />
--------------------------------------------------------------------------------<br />
<br />
local mArguments --initialize lazily<br />
local mHatnote = require('Module:Hatnote')<br />
local libraryUtil = require('libraryUtil')<br />
local checkType = libraryUtil.checkType<br />
local p = {}<br />
<br />
--------------------------------------------------------------------------------<br />
-- List stringification helper functions<br />
--<br />
-- These functions are used for stringifying lists, usually page lists inside<br />
-- the "Y" portion of "For X, see Y" for-see items.<br />
--------------------------------------------------------------------------------<br />
<br />
--default options table used across the list stringification functions<br />
local stringifyListDefaultOptions = {<br />
conjunction = "and",<br />
separator = ",",<br />
altSeparator = ";",<br />
space = " ",<br />
formatted = false<br />
}<br />
<br />
-- Stringifies a list generically; probably shouldn't be used directly<br />
function stringifyList(list, options)<br />
-- Type-checks, defaults, and a shortcut<br />
checkType("stringifyList", 1, list, "table")<br />
if #list == 0 then return nil end<br />
checkType("stringifyList", 2, options, "table", true)<br />
options = options or {}<br />
for k, v in pairs(stringifyListDefaultOptions) do<br />
if options[k] == nil then options[k] = v end<br />
end<br />
local s = options.space<br />
-- Format the list if requested<br />
if options.formatted then list = mHatnote.formatPages(unpack(list)) end<br />
-- Set the separator; if any item contains it, use the alternate separator<br />
local separator = options.separator<br />
--searches display text only<br />
function searchDisp(t, f)<br />
return string.find(string.sub(t, (string.find(t, '|') or 0) + 1), f)<br />
end<br />
for k, v in pairs(list) do<br />
if searchDisp(v, separator) then<br />
separator = options.altSeparator<br />
break<br />
end<br />
end<br />
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"<br />
local conjunction = s .. options.conjunction .. s<br />
if #list == 2 and searchDisp(list[1], "§") or #list > 2 then<br />
conjunction = separator .. conjunction<br />
end<br />
-- Return the formatted string<br />
return mw.text.listToText(list, separator .. s, conjunction)<br />
end<br />
<br />
--DRY function<br />
function conjList (conj, list, fmt)<br />
return stringifyList(list, {conjunction = conj, formatted = fmt})<br />
end<br />
<br />
-- Stringifies lists with "and" or "or"<br />
function p.andList (...) return conjList("and", ...) end<br />
function p.orList (...) return conjList("or", ...) end<br />
<br />
--------------------------------------------------------------------------------<br />
-- For see<br />
--<br />
-- Makes a "For X, see [[Y]]." list from raw parameters. Intended for the<br />
-- {{about}} and {{redirect}} templates and their variants.<br />
--------------------------------------------------------------------------------<br />
<br />
--default options table used across the forSee family of functions<br />
local forSeeDefaultOptions = {<br />
andKeyword = 'and',<br />
title = mw.title.getCurrentTitle().text,<br />
otherText = 'other uses',<br />
forSeeForm = 'For %s, see %s.',<br />
}<br />
<br />
--Collapses duplicate punctuation<br />
function punctuationCollapse (text)<br />
local replacements = {<br />
["%.%.$"] = ".",<br />
["%?%.$"] = "?",<br />
["%!%.$"] = "!",<br />
["%.%]%]%.$"] = ".]]",<br />
["%?%]%]%.$"] = "?]]",<br />
["%!%]%]%.$"] = "!]]"<br />
}<br />
for k, v in pairs(replacements) do text = string.gsub(text, k, v) end<br />
return text<br />
end<br />
<br />
-- Structures arguments into a table for stringification, & options<br />
function p.forSeeArgsToTable (args, from, options)<br />
-- Type-checks and defaults<br />
checkType("forSeeArgsToTable", 1, args, 'table')<br />
checkType("forSeeArgsToTable", 2, from, 'number', true)<br />
from = from or 1<br />
checkType("forSeeArgsToTable", 3, options, 'table', true)<br />
options = options or {}<br />
for k, v in pairs(forSeeDefaultOptions) do<br />
if options[k] == nil then options[k] = v end<br />
end<br />
-- maxArg's gotten manually because getArgs() and table.maxn aren't friends<br />
local maxArg = 0<br />
for k, v in pairs(args) do<br />
if type(k) == 'number' and k > maxArg then maxArg = k end<br />
end<br />
-- Structure the data out from the parameter list:<br />
-- * forTable is the wrapper table, with forRow rows<br />
-- * Rows are tables of a "use" string & a "pages" table of pagename strings<br />
-- * Blanks are left empty for defaulting elsewhere, but can terminate list<br />
local forTable = {}<br />
local i = from<br />
local terminated = false<br />
-- If there is extra text, and no arguments are given, give nil value<br />
-- to not produce default of "For other uses, see foo (disambiguation)"<br />
if options.extratext and i > maxArg then return nil end<br />
-- Loop to generate rows<br />
repeat<br />
-- New empty row<br />
local forRow = {}<br />
-- On blank use, assume list's ended & break at end of this loop<br />
forRow.use = args[i]<br />
if not args[i] then terminated = true end<br />
-- New empty list of pages<br />
forRow.pages = {}<br />
-- Insert first pages item if present<br />
table.insert(forRow.pages, args[i + 1])<br />
-- If the param after next is "and", do inner loop to collect params<br />
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}<br />
while args[i + 2] == options.andKeyword do<br />
if args[i + 3] then <br />
table.insert(forRow.pages, args[i + 3])<br />
end<br />
-- Increment to next "and"<br />
i = i + 2<br />
end<br />
-- Increment to next use<br />
i = i + 2<br />
-- Append the row<br />
table.insert(forTable, forRow)<br />
until terminated or i > maxArg<br />
<br />
return forTable<br />
end<br />
<br />
-- Stringifies a table as formatted by forSeeArgsToTable<br />
function p.forSeeTableToString (forSeeTable, options)<br />
-- Type-checks and defaults<br />
checkType("forSeeTableToString", 1, forSeeTable, "table", true)<br />
checkType("forSeeTableToString", 2, options, "table", true)<br />
options = options or {}<br />
for k, v in pairs(forSeeDefaultOptions) do<br />
if options[k] == nil then options[k] = v end<br />
end<br />
-- Stringify each for-see item into a list<br />
local strList = {}<br />
if forSeeTable then<br />
for k, v in pairs(forSeeTable) do<br />
local useStr = v.use or options.otherText<br />
local pagesStr = p.andList(v.pages, true) or mHatnote._formatLink(mHatnote.disambiguate(options.title))<br />
local forSeeStr = string.format(options.forSeeForm, useStr, pagesStr)<br />
forSeeStr = punctuationCollapse(forSeeStr)<br />
table.insert(strList, forSeeStr)<br />
end<br />
end<br />
if options.extratext then table.insert(strList, punctuationCollapse(options.extratext..'.')) end<br />
-- Return the concatenated list<br />
return table.concat(strList, ' ')<br />
end<br />
<br />
-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps<br />
-- but not blank/whitespace values. Ignores named args and args < "from".<br />
function p._forSee (args, from, options)<br />
local forSeeTable = p.forSeeArgsToTable(args, from, options)<br />
return p.forSeeTableToString(forSeeTable, options)<br />
end<br />
<br />
-- As _forSee, but uses the frame.<br />
function p.forSee (frame, from, options)<br />
mArguments = require('Module:Arguments')<br />
return p._forSee(mArguments.getArgs(frame), from, options)<br />
end<br />
<br />
return p</div>
en>Galobtter