<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ALondon_Gazette_util</id>
	<title>Module:London Gazette util - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ALondon_Gazette_util"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:London_Gazette_util&amp;action=history"/>
	<updated>2026-04-06T02:15:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:London_Gazette_util&amp;diff=1855&amp;oldid=prev</id>
		<title>imported&gt;WOSlinker: use require(&#039;strict&#039;) instead of require(&#039;Module:No globals&#039;)</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:London_Gazette_util&amp;diff=1855&amp;oldid=prev"/>
		<updated>2022-10-21T21:21:55Z</updated>

		<summary type="html">&lt;p&gt;use require(&amp;#039;strict&amp;#039;) instead of require(&amp;#039;Module:No globals&amp;#039;)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- this module is created to support {{London Gazette}}&lt;br /&gt;
&lt;br /&gt;
require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
&lt;br /&gt;
local span_open = &amp;#039;&amp;lt;span style=&amp;quot;font-size:100%; font-weight:normal&amp;quot; class=&amp;quot;error&amp;quot;&amp;gt;&amp;#039;;&lt;br /&gt;
local code_open = &amp;#039;&amp;lt;code style=&amp;quot;color:inherit; border:inherit; padding:inherit;&amp;quot;&amp;gt;&amp;#039;;&lt;br /&gt;
local help_link = &amp;#039; ([[Template:London Gazette#Error messages|help]])&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
local supp_error = mw.ustring.format (&amp;#039;%sinvalid %s&amp;amp;#124;supp=&amp;lt;/code&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;, span_open, code_open, help_link);&lt;br /&gt;
local duplicate_page_error = mw.ustring.format (&amp;#039; %smore than one of %s&amp;amp;#124;page=&amp;lt;/code&amp;gt; and %s&amp;amp;#124;pages=&amp;lt;/code&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;, span_open, code_open, code_open, help_link);&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S E T &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Whether variable is set or not.  A variable is set when it is not nil and not empty.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_set( var )&lt;br /&gt;
	return not (var == nil or var == &amp;#039;&amp;#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O R D I N A L _ S U F F I X &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
render a numerical text string in ordinal form suitable for English language use.  In this module, num_str is&lt;br /&gt;
limited by calling functions to the integer values 1-99.  The argument num_str must be known to be set before&lt;br /&gt;
this function is called.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function ordinal_suffix (num_str)&lt;br /&gt;
	local lsd;																	-- least significant digit&lt;br /&gt;
	local suffixes = {[&amp;#039;1&amp;#039;] = &amp;#039;st&amp;#039;, [&amp;#039;2&amp;#039;] = &amp;#039;nd&amp;#039;, [&amp;#039;3&amp;#039;] = &amp;#039;rd&amp;#039;};				-- table of suffixes except &amp;#039;th&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	if num_str:match (&amp;#039;^1[1-3]$&amp;#039;) then											-- check the 11-13 odd balls first to get them out of the way&lt;br /&gt;
		return num_str .. &amp;#039;th&amp;#039;;													-- 11th, 12th, 13th&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	lsd = num_str:match (&amp;#039;^%d?(%d)$&amp;#039;);											-- all other numbers: get the least significant digit&lt;br /&gt;
	return num_str .. (suffixes[lsd] or &amp;#039;th&amp;#039;);									-- append the suffix from the suffixes table or default to &amp;#039;th&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ P A G E _ P A R A M &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determine the value to be assigned to the specified cs1|2 |page= or |pages= parameter in {{London Gazette}}.&lt;br /&gt;
The arguments |param=page and |param=pages specify which of the cs1|2 parameters |page= or |pages= for which this&lt;br /&gt;
function is to create a value.&lt;br /&gt;
&lt;br /&gt;
This function inspects the content of the |page= and |pages= parameters, along with the |param= specifier.  From&lt;br /&gt;
this information it creates a value appropriate for the specified |page= or |pages= parameter.  Only one will&lt;br /&gt;
have a value, the other will get an empty string.&lt;br /&gt;
&lt;br /&gt;
This function is called twice from {{London Gazette}}; once for each of cs1 |page= and |pages= parameters:&lt;br /&gt;
	|page={{#invoke:Gazette util|make_page_param|param=page|page={{{page|}}}|pages={{{pages|}}}}}&lt;br /&gt;
	|pages={{#invoke:Gazette util|make_page_param|param=pages|page={{{page|}}}|pages={{{pages|}}}}}&lt;br /&gt;
&lt;br /&gt;
except for the lvalue and the rvalue assigned to |param=, the two calls must be identical else odd results.&lt;br /&gt;
&lt;br /&gt;
|page= or |pages= without a comma, hyphen, or en dash separator → cs1 |page=&lt;br /&gt;
|page= or |pages= with a separator → cs1 |pages=&lt;br /&gt;
&lt;br /&gt;
Hyphen separator characters are converted to en dash characters.  Any white space around hyphen and en dash&lt;br /&gt;
separators is removed.&lt;br /&gt;
&lt;br /&gt;
If both |page= and |pages= are set, this function mimics cs1|2 and chooses |page=.&lt;br /&gt;
&lt;br /&gt;
Another function, page_error() is required for error messaging because we don&amp;#039;t want to dump css markup into a&lt;br /&gt;
parameter value that will be included in the cs1|2 metadata.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function p.make_page_param (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
	local page_or_pages;&lt;br /&gt;
&lt;br /&gt;
	page_or_pages = args.page or args.unnamed or args.pages;					-- only one; prefer |page=&lt;br /&gt;
	&lt;br /&gt;
	if is_set (page_or_pages) then&lt;br /&gt;
		if &amp;#039;pages&amp;#039; == args.param then&lt;br /&gt;
			if page_or_pages:match (&amp;#039;[,%-–]&amp;#039;) then								-- only for |pages= parameter&lt;br /&gt;
				page_or_pages = mw.ustring.gsub (page_or_pages, &amp;#039;%s*[%-–]%s*&amp;#039;, &amp;#039;–&amp;#039;);	-- hyphen to en dash; remove spaces&lt;br /&gt;
				return page_or_pages;											-- has separator character so make the parameter |pages=&lt;br /&gt;
			else&lt;br /&gt;
				return &amp;#039;&amp;#039;;														-- no separator so value will be assigned to |page=&lt;br /&gt;
			end&lt;br /&gt;
		elseif &amp;#039;page&amp;#039; == args.param then&lt;br /&gt;
			if page_or_pages:match (&amp;#039;[,%-–]&amp;#039;) then								-- only for |pages= parameter&lt;br /&gt;
				return &amp;#039;&amp;#039;;														-- has separator so value will be assigned to |pages=&lt;br /&gt;
			else&lt;br /&gt;
				return page_or_pages;											-- no separator character so make the parameter |page=&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;#039;&amp;#039;;															-- |param= something else&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return &amp;#039;&amp;#039;;																	-- if here no pagination or not correct |page= or |pages= parameter&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P A G E _ E R R O R &amp;gt;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Inspect page number parameters and return an error message that will be appended to the end of the {{cite magazine}}&lt;br /&gt;
template rendering.  Error messages are handled this way so that the error message is not made part of the cs1|2&lt;br /&gt;
citation&amp;#039;s metadata.&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Gazette util|page_error|page={{{page|}}}|pages={{{pages|}}}}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function p.page_error (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
&lt;br /&gt;
	if is_set (args.page) and is_set (args.pages) then&lt;br /&gt;
		return duplicate_page_error;											-- both of |page= and |pages= are set&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; T Y P E _ P A R A M &amp;gt;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
set the value that is assigned to the cite magazine |type= parameter using the values of the London Gazette&lt;br /&gt;
|supp= and |display-supp= parameters&lt;br /&gt;
&lt;br /&gt;
Only limited |supp= values will set the type value.  These are: &amp;#039;y&amp;#039; or a number 1-99.&lt;br /&gt;
&lt;br /&gt;
row numbers in comments apply to the table in Template_talk:London_Gazette#Rewrite_as_wrapper_around_template:cite_news&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function p.type_param (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	if not is_set (args[&amp;#039;display-supp&amp;#039;]) and not is_set (args.supp) then		-- when both |display-supp= and |supp= are not set&lt;br /&gt;
		return &amp;#039;&amp;#039;;																-- [row 1] not a supplement so no display&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	args.supp = args.supp and args.supp:lower();								-- make text values lower case&lt;br /&gt;
&lt;br /&gt;
	if not is_set (args[&amp;#039;display-supp&amp;#039;]) and is_set (args.supp) then			-- when only |supp= is set&lt;br /&gt;
		if &amp;#039;y&amp;#039; == args.supp then&lt;br /&gt;
			return &amp;#039;Supplement&amp;#039;;												-- [row 2] the first or only supplement&lt;br /&gt;
		elseif args.supp:match (&amp;#039;^%d%d?$&amp;#039;) then									-- one or two digits&lt;br /&gt;
				return ordinal_suffix (args.supp) .. &amp;#039; supplement&amp;#039;;				-- [row 3] for the 1st-99th supplement&lt;br /&gt;
		else&lt;br /&gt;
			return supp_error;													-- [row 4] any other text not supported show an error message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (args[&amp;#039;display-supp&amp;#039;]) and not is_set (args.supp) then			-- when only |display-supp= is set&lt;br /&gt;
		if args[&amp;#039;display-supp&amp;#039;]:match (&amp;#039;^%d%d?$&amp;#039;) then							-- one or two digits&lt;br /&gt;
			return ordinal_suffix (args[&amp;#039;display-supp&amp;#039;]) .. &amp;#039; supplement&amp;#039;;		-- [row 7] for the 1st-99th supplement&lt;br /&gt;
		elseif &amp;#039;y&amp;#039; == args[&amp;#039;display-supp&amp;#039;] then&lt;br /&gt;
			return &amp;#039;Supplement&amp;#039;;												-- [row 6] unnumbered supplement in /page/ space&lt;br /&gt;
		else&lt;br /&gt;
			return args[&amp;#039;display-supp&amp;#039;];										-- [row 11] user specified text; supplement is not in supplement space (a Gazette website error)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
																				-- here when both |display-supp= and |supp= are set&lt;br /&gt;
	if args[&amp;#039;display-supp&amp;#039;]:match (&amp;#039;^%d%d?$&amp;#039;) then								-- supplement number&lt;br /&gt;
		if &amp;#039;y&amp;#039; == args.supp or (args[&amp;#039;display-supp&amp;#039;] == args.supp) then&lt;br /&gt;
			return ordinal_suffix (args[&amp;#039;display-supp&amp;#039;]) .. &amp;#039; supplement&amp;#039;;		-- [rows 8, 9]&lt;br /&gt;
		else																	-- |supp= is not a number or number isn&amp;#039;t same as number in |display-supp=&lt;br /&gt;
			return supp_error;													-- [row 10] different values are ambiguous&lt;br /&gt;
		end&lt;br /&gt;
	else																		-- not a supplement number&lt;br /&gt;
		if (&amp;#039;y&amp;#039; == args.supp) and (&amp;#039;none&amp;#039; == args[&amp;#039;display-supp&amp;#039;]) then&lt;br /&gt;
			return &amp;#039;&amp;#039;;															-- [row 5] for the case when a /page/ is in /supplement/ space &lt;br /&gt;
		elseif (&amp;#039;y&amp;#039; == args.supp) or args.supp:match (&amp;#039;^%d%d?$&amp;#039;) or not is_set (args.supp) then&lt;br /&gt;
			return args[&amp;#039;display-supp&amp;#039;];										-- [rows 12, 13] user specified text&lt;br /&gt;
		else&lt;br /&gt;
			return supp_error;													-- [row 14] any other |supp= value not supported show an error message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; U R L _ C I T Y &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
sets the city element of the url path according to |city= value; defaults to London&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function url_city (city_param)&lt;br /&gt;
	local city_names = {[&amp;#039;b&amp;#039;] = &amp;#039;Belfast&amp;#039;, [&amp;#039;belfast&amp;#039;] = &amp;#039;Belfast&amp;#039;, [&amp;#039;e&amp;#039;] = &amp;#039;Edinburgh&amp;#039;, [&amp;#039;edinburgh&amp;#039;] = &amp;#039;Edinburgh&amp;#039;};&lt;br /&gt;
	&lt;br /&gt;
	city_param = city_param and city_param:lower();								-- lower() to index into the city_names table&lt;br /&gt;
&lt;br /&gt;
	return city_names[city_param] or &amp;#039;London&amp;#039;;									-- the city, or default to London&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
--[[--------------------------&amp;lt; U R L _ P A G E &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
sets the page number element of the url path according to |page= or |pages=, and the value assigned to |supp=&lt;br /&gt;
parameter.  This function assumes that supplements may have page numbering that are digits prefixed with one or&lt;br /&gt;
two letters: B1, B41, RH2, etc; also assumes that regular issues have digit-only page numbers.&lt;br /&gt;
&lt;br /&gt;
Only limited |supp= values will set the page number path element.  These are: &amp;#039;y&amp;#039; or a number 1-99.&lt;br /&gt;
&lt;br /&gt;
From issue 1610–1619 the gazette has both digit page numbers and digit + alpha page numbers.  It appears that the&lt;br /&gt;
issue numbers did not advance properly in this period so the website has page numbers like &amp;#039;1.a&amp;#039; and &amp;#039;3.a.a&amp;#039; plus&lt;br /&gt;
the usual digit page number &amp;#039;1&amp;#039;, &amp;#039;3&amp;#039;, etc for all of issues 1610–1619.  There were no supplements during this period&lt;br /&gt;
so this function handles the 1610–1619 issues separately.  The alpha character is always &amp;#039;a&amp;#039; and is always separated&lt;br /&gt;
from the digits and other alpha by a dot.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function url_page (page, supp, issue)&lt;br /&gt;
	issue = tonumber (issue);													-- for issues 1610–1619 comparison&lt;br /&gt;
	if issue and (6610 &amp;lt;= issue and 6619 &amp;gt;= issue) then							-- if one of these oddball issues with numeric + alpha page numbers (~ Sep–Oct 1727)&lt;br /&gt;
		return page:match (&amp;#039;^%d+%.?[a%.]+&amp;#039;);									-- there are no supplements in this range so we&amp;#039;re done&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if is_set (supp) then														-- all other issues&lt;br /&gt;
		if (&amp;#039;y&amp;#039; == supp) or supp:match (&amp;#039;^%d%d?$&amp;#039;) then&lt;br /&gt;
			page = page:match (&amp;#039;^%a?%a?%d+&amp;#039;);									-- one or two letters followed by digits or just digits (supplement to issue 61608)&lt;br /&gt;
		else&lt;br /&gt;
			page = page:match (&amp;#039;^%d+&amp;#039;);											-- |supp= set to an unexpected value, so one or more digits only&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		page = page:match (&amp;#039;^%d+&amp;#039;);												-- |supp= not set, so one or more digits only&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return page or &amp;#039;&amp;#039;;															-- at minimum return empty string for concatenation&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; U R L _ P A G E _ O R _ S U P P L E M E N T &amp;gt;----------------------------------&lt;br /&gt;
&lt;br /&gt;
sets the page/supplement element of the url path according to |supp= value; defaults to page&lt;br /&gt;
&lt;br /&gt;
Only limited |supp= values will set the page/supplement path element to /supplement/.  These are: &amp;#039;y&amp;#039; or a number 1-99&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function url_page_or_supplement (supp_param)&lt;br /&gt;
	supp_param = (supp_param and supp_param:lower()) or &amp;#039;&amp;#039;;						--make sure lower case for comparisons&lt;br /&gt;
	&lt;br /&gt;
	if (&amp;#039;y&amp;#039; == supp_param) or supp_param:match (&amp;#039;^%d%d?$&amp;#039;) then&lt;br /&gt;
		return &amp;#039;supplement&amp;#039;;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;page&amp;#039;;															-- anything else&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
--[[--------------------------&amp;lt; U R L _ P A R A M &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Build a url given |city=, |issue=, |supp=, and one of |page= or |pages=; result is assigned to |url=&lt;br /&gt;
&lt;br /&gt;
|url={{#invoke:Gazette util|url_param|city={{{city|}}}|issue={{{issue}}}|supp={{{supp|}}}|page={{{page|}}}|pages={{{pages|}}}}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function p.url_param (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
	local pg = args.page or args.pages or &amp;#039;&amp;#039;;									-- first set parameter or empty string&lt;br /&gt;
&lt;br /&gt;
	local url_table = {															-- a table of the various url parts&lt;br /&gt;
		&amp;#039;https://www.thegazette.co.uk&amp;#039;,											-- static domain name&lt;br /&gt;
		url_city (args.city),													-- default to London&lt;br /&gt;
		&amp;#039;issue&amp;#039;,																-- static path text&lt;br /&gt;
		args.issue,																-- issue number&lt;br /&gt;
		url_page_or_supplement (args.supp),										-- either of /page/ or /supplement/ according to the state of |supp=&lt;br /&gt;
		url_page (pg, args.supp, args.issue)									-- pages: digits only; supplements: optional letter followed by 1 or more digits&lt;br /&gt;
		};&lt;br /&gt;
	&lt;br /&gt;
	return table.concat (url_table, &amp;#039;/&amp;#039;);										-- concatenate all of the parts together and done&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p;&lt;/div&gt;</summary>
		<author><name>imported&gt;WOSlinker</name></author>
	</entry>
</feed>