<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tachyony.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_iucn</id>
	<title>Module:Cite iucn - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tachyony.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_iucn"/>
	<link rel="alternate" type="text/html" href="https://wiki.tachyony.co.uk/w/index.php?title=Module:Cite_iucn&amp;action=history"/>
	<updated>2026-05-15T13:31:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://wiki.tachyony.co.uk/w/index.php?title=Module:Cite_iucn&amp;diff=12521&amp;oldid=prev</id>
		<title>Tachyony: ←Created page with &#039;require(&#039;Module:No globals&#039;); local getArgs = require (&#039;Module:Arguments&#039;).getArgs;  local amendment_pattern = &#039;%s*%(amended version of (%d%d%d%d) assessment%)&#039;;...&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tachyony.co.uk/w/index.php?title=Module:Cite_iucn&amp;diff=12521&amp;oldid=prev"/>
		<updated>2022-03-30T17:47:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/wiki/WP:AES&quot; class=&quot;mw-redirect&quot; title=&quot;WP:AES&quot;&gt;←&lt;/a&gt;Created page with &amp;#039;require(&amp;#039;Module:No globals&amp;#039;); local getArgs = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;  local amendment_pattern = &amp;#039;%s*%(amended version of (%d%d%d%d) assessment%)&amp;#039;;...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;Module:No globals&amp;#039;);&lt;br /&gt;
local getArgs = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;&lt;br /&gt;
&lt;br /&gt;
local amendment_pattern = &amp;#039;%s*%(amended version of (%d%d%d%d) assessment%)&amp;#039;;&lt;br /&gt;
local errata_pattern = &amp;#039;%s*%(errata version published in (%d%d%d%d)%)&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I U C N _ I D E N T I F I E R S _ G E T &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
cs1|2 templates cite single sources;  when the identifiers in |doi=, |id=, and |page= are different from each other&lt;br /&gt;
then the template is attempting to cite multiple sources.  This function evaluates the identifier portions of these&lt;br /&gt;
parameters. returns seven values: identifyier parts (or nil when parameter not used) and a message (nil on success,&lt;br /&gt;
error message else)&lt;br /&gt;
&lt;br /&gt;
the identifier portions of the several parameters must be properly formed&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iucn_identifiers_get (args)&lt;br /&gt;
	local doi_taxon_ID, doi_assesment_ID&lt;br /&gt;
	local page_taxon_ID, page_assesment_ID&lt;br /&gt;
	local url_taxon_ID, url_assesment_ID&lt;br /&gt;
	local msg&lt;br /&gt;
	&lt;br /&gt;
	if args.doi then&lt;br /&gt;
		doi_taxon_ID, doi_assesment_ID = args.doi:match (&amp;#039;[Tt](%d+)[Aa](%d+)%.e[ns]$&amp;#039;)&lt;br /&gt;
		if not doi_taxon_ID then&lt;br /&gt;
			msg = &amp;#039;malformed |doi= identifier&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if args.page then&lt;br /&gt;
		page_taxon_ID, page_assesment_ID = args.page:match (&amp;#039;^[eE]%.[Tt](%d+)[Aa](%d+)$&amp;#039;)&lt;br /&gt;
		if not page_taxon_ID then&lt;br /&gt;
			msg = &amp;#039;malformed |page= identifier&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if args.url then&lt;br /&gt;
		if args.url:match (&amp;#039;https://www.iucnredlist.org/species/&amp;#039;) then			-- must be a &amp;#039;new-form&amp;#039; url&lt;br /&gt;
			url_taxon_ID, url_assesment_ID = args.url:match (&amp;#039;/species/(%d+)/(%d+)&amp;#039;)&lt;br /&gt;
			if not url_taxon_ID then&lt;br /&gt;
				msg = &amp;#039;malformed |url= identifier&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not msg then&lt;br /&gt;
		if doi_taxon_ID and page_taxon_ID then&lt;br /&gt;
			if (doi_taxon_ID ~= page_taxon_ID or ((doi_assesment_ID ~= page_assesment_ID) and not args.errata)) then&lt;br /&gt;
				msg = &amp;#039;|doi= / |page= mismatch&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if doi_taxon_ID and url_taxon_ID then&lt;br /&gt;
			if (doi_taxon_ID ~= url_taxon_ID or ((doi_assesment_ID ~= url_assesment_ID) and not args.errata)) then&lt;br /&gt;
				msg = &amp;#039;|doi= / |url= mismatch&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if page_taxon_ID and url_taxon_ID then&lt;br /&gt;
			if (page_taxon_ID ~= url_taxon_ID or ((page_assesment_ID ~= url_assesment_ID) and not args.errata)) then&lt;br /&gt;
				msg = &amp;#039;|page= / |url= mismatch&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if msg then&lt;br /&gt;
		msg = &amp;#039;&amp;lt;span class=&amp;quot;error&amp;quot; style=&amp;quot;font-size:100%&amp;quot;&amp;gt;{{cite iucn}}: error: &amp;#039; .. msg .. &amp;#039; ([[Template:Cite iucn|help]])&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return doi_taxon_ID, doi_assesment_ID, page_taxon_ID, page_assesment_ID, msg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I U C N _ V O L U M E _ C H E C K &amp;gt;--------------------------------------------&lt;br /&gt;
&lt;br /&gt;
compares volume in |volume= (if present) against year in |date= or |year= (if present) against volume in |doi= (if present)&lt;br /&gt;
&lt;br /&gt;
returns nil if all that are present are correct; message else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iucn_volume_check (args)&lt;br /&gt;
	local vol = args.volume;&lt;br /&gt;
	local date = args.date or args.year;&lt;br /&gt;
	local doi = args.doi and args.doi:match (&amp;#039;[Ii][Uu][Cc][Nn]%.[Uu][Kk]%.(%d%d%d%d)&amp;#039;)&lt;br /&gt;
	local msg&lt;br /&gt;
	&lt;br /&gt;
	if vol and date then&lt;br /&gt;
		msg = (vol ~= date) and &amp;#039;|volume= / |date= mismatch&amp;#039; or msg&lt;br /&gt;
	end&lt;br /&gt;
	if vol and doi then&lt;br /&gt;
		msg = ((vol ~= doi) and not args.amends) and &amp;#039;|volume= / |doi= mismatch&amp;#039; or msg&lt;br /&gt;
	end&lt;br /&gt;
	if date and doi then&lt;br /&gt;
		msg = ((doi ~= date) and not args.amends) and &amp;#039;|date= / |doi= mismatch&amp;#039; or msg&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return msg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C I T E &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Wraps {{cite journal}}:&lt;br /&gt;
     takes cite journal parameters but updates old style url using electronic page number&lt;br /&gt;
     page should be in format e.T13922A45199653&lt;br /&gt;
     the url uses                13922/45199653&lt;br /&gt;
     so we need to extract the number between T and A (taxon ID) and the number after A (assessment ID)&lt;br /&gt;
     the target url is https://www.iucnredlist.org/species/13922/45199653&lt;br /&gt;
     usage: {{#invoke:iucn|cite}}&lt;br /&gt;
     template: {{Template:Cite iucn}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cite (frame)&lt;br /&gt;
	local error_msgs = {};														-- holds error messages for rendering&lt;br /&gt;
	local maint_msgs = {};														-- holds hidden maint messages for rendering&lt;br /&gt;
	local namespace = mw.title.getCurrentTitle().namespace;						-- used for categorization&lt;br /&gt;
	local args = getArgs (frame);												-- local copy of template arguments&lt;br /&gt;
&lt;br /&gt;
	local missing_title = not args.title										-- special case that results from script writing {{cite iucn}} template from bare iucn url&lt;br /&gt;
																				-- don&amp;#039;t duplicate cs1|2 error message; don&amp;#039;t duplicate {{cite iucn}} error cat&lt;br /&gt;
																				-- TODO: remove this when the error category has been cleared of missing title errors&lt;br /&gt;
&lt;br /&gt;
	if args.title and (args.title:match (errata_pattern) or args.title:match (amendment_pattern)) then&lt;br /&gt;
		table.insert (maint_msgs, &amp;#039;title has extraneous text&amp;#039;);					-- announce that this template has has errata or amendment text&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local doi_taxon_ID, doi_assesment_ID										-- all of these contain the same identifying info in slightly&lt;br /&gt;
	local page_taxon_ID, page_assesment_ID										-- different forms. when any combination of these is present,&lt;br /&gt;
	local msg																	-- this holds error messages; nil on success&lt;br /&gt;
&lt;br /&gt;
	doi_taxon_ID, doi_assesment_ID, page_taxon_ID, page_assesment_ID, msg = iucn_identifiers_get (args);&lt;br /&gt;
	if msg then&lt;br /&gt;
		table.insert (error_msgs, msg);											-- malformed or mismatched identifiers&lt;br /&gt;
	end&lt;br /&gt;
	args.id = nil																-- unset; not supported&lt;br /&gt;
&lt;br /&gt;
	local url_taxon_ID = page_taxon_ID or doi_taxon_ID;							-- select for use in url that we will create&lt;br /&gt;
	local url_assesment_ID = page_assesment_ID  or doi_assesment_ID&lt;br /&gt;
	&lt;br /&gt;
	local url = args.url&lt;br /&gt;
	if url then&lt;br /&gt;
		if url:find (&amp;#039;iucnredlist.org/details/&amp;#039;, 1, true) then					-- old-form url&lt;br /&gt;
			if url_taxon_ID then												-- when there is an identifier&lt;br /&gt;
				url = nil														-- unset; we&amp;#039;ll create new url below&lt;br /&gt;
			else																-- here when old-form but no identifier that we can use to create new url&lt;br /&gt;
				args.url = args.url:gsub (&amp;quot;http:&amp;quot;, &amp;quot;https:&amp;quot;)					-- sometimes works with redirect on iucn site&lt;br /&gt;
			end&lt;br /&gt;
			table.insert (maint_msgs, &amp;#039;old-form url&amp;#039;)							-- announce that this template has has an old-form url&lt;br /&gt;
		elseif url:find (&amp;#039;iucnredlist.org/species/&amp;#039;, 1, true) then				-- new-form url&lt;br /&gt;
--			table.insert (maint_msgs, &amp;#039;new-form url&amp;#039;)				--TODO: restore this line when most new-form urls have been removed from article space		-- announce that this template has has an new-form url&lt;br /&gt;
		else&lt;br /&gt;
			table.insert (maint_msgs, &amp;#039;unknown url&amp;#039;)							-- announce that this template has has some sort of url we don&amp;#039;t recognize&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not url then																-- when no url or unset old-form url&lt;br /&gt;
		if url_taxon_ID then&lt;br /&gt;
			args.url = &amp;quot;https://www.iucnredlist.org/species/&amp;quot; .. url_taxon_ID .. &amp;#039;/&amp;#039; .. url_assesment_ID&lt;br /&gt;
		else&lt;br /&gt;
			table.insert (maint_msgs, &amp;#039;no identifier&amp;#039;)							-- TODO: raise this to  error status?&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add journal if not provided (TODO decide if this should override provided value)&lt;br /&gt;
	if not args[&amp;#039;journal&amp;#039;] and not args[&amp;#039;work&amp;#039;] then&lt;br /&gt;
		args[&amp;#039;journal&amp;#039;] = &amp;quot;[[IUCN Red List|IUCN Red List of Threatened Species]]&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	msg = iucn_volume_check (args);												-- |volume=, |year= (|date=), |doi= must all refer to the same volume&lt;br /&gt;
	if msg then&lt;br /&gt;
		table.insert (maint_msgs, msg);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not args.volume and (args.year or args.date) then&lt;br /&gt;
		args.volume = args.year or args.date&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if args.errata then&lt;br /&gt;
		args[&amp;#039;orig-date&amp;#039;] = &amp;#039;errata version of &amp;#039; .. (args.year or args.date or args.volume) .. &amp;#039; assessment&amp;#039;;&lt;br /&gt;
		args.date = args.errata;												-- update publication data to errata year&lt;br /&gt;
		args.year = nil;														-- unset these as no longer needed&lt;br /&gt;
		args.errata = nil;&lt;br /&gt;
	elseif args.amends then&lt;br /&gt;
		args[&amp;#039;orig-date&amp;#039;] = &amp;#039;amended version of &amp;#039; .. args.amends .. &amp;#039; assessment&amp;#039;;&lt;br /&gt;
		args.amends = nil;														-- unset as no longer needed&lt;br /&gt;
	end&lt;br /&gt;
																				-- add free-to-read icon to mark a correctly formed doi&lt;br /&gt;
	args[&amp;#039;doi-access&amp;#039;] = args.doi and args.doi:match (&amp;#039;10%.2305/[Ii][Uu][Cc][Nn].+[Tt]%d+[Aa]%d+%.[Ee][NnSs]&amp;#039;) and &amp;#039;free&amp;#039; or nil&lt;br /&gt;
		&lt;br /&gt;
	return frame:expandTemplate{ title = &amp;#039;cite journal&amp;#039;, args = args } ..							-- the template&lt;br /&gt;
		(((0 == #error_msgs) and missing_title) and (&amp;#039;[[Category:cite iucn errors]]&amp;#039;) or &amp;#039;&amp;#039;) ..		-- special case to not duplicate cs1|2 err msg or cite iucn error cat&lt;br /&gt;
		((0 &amp;lt; #error_msgs) and table.concat (error_msgs, &amp;#039;, &amp;#039;) or &amp;#039;&amp;#039;) ..							-- the error messages&lt;br /&gt;
		(((0 &amp;lt; #error_msgs) and (0 == namespace)) and (&amp;#039;[[Category:cite iucn errors]]&amp;#039;) or &amp;#039;&amp;#039;) ..	-- error category when in mainspace&lt;br /&gt;
		((0 &amp;lt; #maint_msgs) and (&amp;#039;&amp;lt;span class=&amp;quot;citation-comment&amp;quot; style=&amp;quot;display: none; color: #33aa33; margin-left: 0.3em;&amp;quot;&amp;gt;&amp;#039; .. table.concat (maint_msgs, &amp;#039;, &amp;#039;) .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;) or &amp;#039;&amp;#039;) ..	-- the maint messages&lt;br /&gt;
		(((0 &amp;lt; #maint_msgs) and (0 == namespace)) and (&amp;#039;[[Category:cite iucn maint]]&amp;#039;) or &amp;#039;&amp;#039;)		-- maint category when in mainspace&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A U T H O R _ L I S T _ M A K E &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
creates a list of individual |authorn= parameters from the list of names provided in the raw iucn citation.  names&lt;br /&gt;
must have the form: Surname, I. (more than one &amp;#039;I.&amp;#039; pair allowed but no spaces between I. pairs)&lt;br /&gt;
&lt;br /&gt;
assumes that parenthetical text at the end of the author-name-list is a collaboration&lt;br /&gt;
	Name, I.I., &amp;amp; Name, I.I. (Colaboration name)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function author_names_get (raw_iucn_cite)&lt;br /&gt;
	local list = {};															-- table that holds name list parts&lt;br /&gt;
	local author_names = raw_iucn_cite:match (&amp;#039;^([^%d]-)%s+%d%d%d%d&amp;#039;);			-- extract author name-list from raw iucn citation&lt;br /&gt;
	local collaboration = author_names:match (&amp;#039;%s*(%b())$&amp;#039;);					-- get collaboration name if it exists&lt;br /&gt;
&lt;br /&gt;
	if collaboration then														-- when there is a colaboration&lt;br /&gt;
		collaboration = collaboration:gsub (&amp;#039;[%(%)]&amp;#039;, &amp;#039;&amp;#039;);						-- remove bounding parentheses&lt;br /&gt;
		author_names = author_names:gsub (&amp;#039;%s*(%b())$&amp;#039;, &amp;#039;&amp;#039;);					-- and remove collaboration from author-name-list&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local names = author_names:gsub (&amp;#039;%.?,?%s+&amp;amp;%s+&amp;#039;, &amp;#039;.|&amp;#039;):gsub (&amp;#039;%.,%s+&amp;#039;, &amp;#039;.|&amp;#039;);	-- replace &amp;#039;separators&amp;#039; (&amp;lt;dot&amp;gt;&amp;lt;comma&amp;gt;&amp;lt;space&amp;gt; and &amp;lt;opt. dot&amp;gt;&amp;lt;opt. comma&amp;gt;&amp;lt;space&amp;gt;&amp;lt;ampersand&amp;gt;&amp;lt;space&amp;gt;) with &amp;lt;dot&amp;gt;&amp;lt;pipe&amp;gt;&lt;br /&gt;
	names = names:gsub (&amp;#039;(%.%u),&amp;#039;, &amp;#039;%1.|&amp;#039;);										-- special case for when last initial is missing its trailing dot&lt;br /&gt;
	list = mw.text.split (names, &amp;#039;|&amp;#039;);											-- split the string on the pipes into entries in list{}&lt;br /&gt;
	&lt;br /&gt;
	if 0 == #list then&lt;br /&gt;
		return table.concat ({&amp;#039;|author=&amp;#039;, author_names})						-- no &amp;#039;names&amp;#039; of the proper form; return the original as a single |author= parameter&lt;br /&gt;
	else&lt;br /&gt;
		for i, name in ipairs (list) do											-- spin through the list and &lt;br /&gt;
--			list[i] = table.concat ({&amp;#039;|author&amp;#039;, i, &amp;#039;=&amp;#039;, name});					-- add |authorn= parameter names&lt;br /&gt;
			list[i] = table.concat ({&amp;#039;|author&amp;#039;, (i == 1) and &amp;#039;&amp;#039; or i, &amp;#039;=&amp;#039;, name});	-- add |authorn= parameter names; create |author= instead of |author1=&lt;br /&gt;
		end&lt;br /&gt;
		if collaboration then&lt;br /&gt;
			table.insert (list, table.concat ({&amp;#039;|collaboration&amp;#039;, &amp;#039;=&amp;#039;, collaboration}));	-- add |collaboration= parameter&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat (list, &amp;#039; &amp;#039;);										-- make a big string and return that&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; T I T L E _ G E T &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
extract and format citation title; attempts to get the italic right&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039; (amended or errata title)&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039; ssp. &amp;#039;&amp;#039;subspecies&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039; subsp. &amp;#039;&amp;#039;subspecies&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039; var. &amp;#039;&amp;#039;variety&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;binomen&amp;#039;&amp;#039; subvar. &amp;#039;&amp;#039;subvariety&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
all of the above may have trailing amended or errata text in parentheses&lt;br /&gt;
&lt;br /&gt;
TODO: are there others?&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function title_get (raw_iucn_cite)&lt;br /&gt;
	local title = raw_iucn_cite:match (&amp;#039;%d%d%d%d%.%s+(.-)%s*%. The IUCN Red List of Threatened Species&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
	local patterns = {															-- tables of string.match patterns [1] and string.gsub patterns [2]&lt;br /&gt;
		{&amp;#039;(.-)%sssp%.%s+(.-)%s(%b())$&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; ssp. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039; %3&amp;quot;},				-- binomen ssp. subspecies (zoology) with errata or amended text&lt;br /&gt;
		{&amp;#039;(.-)%sssp%.%s+(.+)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; ssp. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039;&amp;quot;},							-- binomen ssp. subspecies (zoology)&lt;br /&gt;
		{&amp;#039;(.-)%ssubsp%.%s+(.-)%s(%b())$&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; subsp. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039; %3&amp;quot;},			-- binomen subsp. subspecies (botany) with errata or amended text&lt;br /&gt;
		{&amp;#039;(.-)%ssubsp%.%s+(.+)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; subsp. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039;&amp;quot;},						-- binomen subsp. subspecies (botany)&lt;br /&gt;
		{&amp;#039;(.-)%svar%.%s+(.-)%s+(%b())$&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; var. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039; %3&amp;quot;},				-- binomen var. variety (botany) with errata or amended text&lt;br /&gt;
		{&amp;#039;(.-)%svar%.%s+(.+)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; var. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039;&amp;quot;},							-- binomen var. variety (botany)&lt;br /&gt;
		{&amp;#039;(.-)%ssubvar%.%s+(.-)%s(%b())$&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; subvar. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039; %3&amp;quot;},			-- binomen subvar. subvariety (botany) with errata or amended text&lt;br /&gt;
		{&amp;#039;(.-)%ssubvar%.%s+(.+)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; subvar. &amp;#039;&amp;#039;%2&amp;#039;&amp;#039;&amp;quot;},						-- binomen subvar. subvariety (botany)&lt;br /&gt;
		{&amp;#039;(.-)%s*(%b())$&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039; %2&amp;quot;},										-- binomen with errata or amended text&lt;br /&gt;
		{&amp;#039;(.+)&amp;#039;, &amp;quot;&amp;#039;&amp;#039;%1&amp;#039;&amp;#039;&amp;quot;},														-- binomen&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
	for i, v in ipairs (patterns) do											-- spin through the patterns&lt;br /&gt;
		if title:match (v[1]) then												-- when a match&lt;br /&gt;
			title = title:gsub (v[1], v[2]);									-- add italics &lt;br /&gt;
			break;																-- and done&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat ({&amp;#039; |title=&amp;#039;, title});									-- return the |title= parameter&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ C I T E _ I U C N &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
parses apart an iucn-format citation copied from their webpage and reformats that into a {{cite iucn}} template for substing&lt;br /&gt;
&lt;br /&gt;
automatic substing by User:AnomieBOT/docs/TemplateSubster&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_cite_iucn (frame)&lt;br /&gt;
	local args = getArgs (frame);&lt;br /&gt;
	local raw_iucn_cite = args[1];&lt;br /&gt;
	&lt;br /&gt;
	local template = {&amp;#039;{{cite iucn &amp;#039;};											-- table that holds the {{cite iucn}} template as it is being assembled&lt;br /&gt;
	local year, volume, page, doi, accessdate;&lt;br /&gt;
&lt;br /&gt;
	year = raw_iucn_cite:match (&amp;#039;^%D+(%d%d%d%d)&amp;#039;);&lt;br /&gt;
	volume, page = raw_iucn_cite:match (&amp;#039;(%d%d%d%d):%s+(e%.T%d+A+%d+)%.%s&amp;#039;);&lt;br /&gt;
	doi = raw_iucn_cite:match (&amp;#039;10%.2305/IUCN%.UK%.[%d%-]+%.RLTS%.T%d+A%d+%.e[ns]&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
--	accessdate = raw_iucn_cite:match (&amp;#039;Downloaded on (.-)%.?$&amp;#039;):gsub (&amp;#039;^0&amp;#039;, &amp;#039;&amp;#039;);	-- strips leading 0 in day 01 January 2020 -&amp;gt; 1 January 2020&lt;br /&gt;
	accessdate = raw_iucn_cite:match (&amp;#039;Accessed on (.-)%.?$&amp;#039;) or raw_iucn_cite:match (&amp;#039;Downloaded on (.-)%.?$&amp;#039;);	-- &amp;#039;Downloaded&amp;#039; → &amp;#039;Accessed&amp;#039; change occured December 2021;&lt;br /&gt;
	accessdate = accessdate:gsub (&amp;#039;^0&amp;#039;, &amp;#039;&amp;#039;);									-- strips leading 0 in day 01 January 2020 -&amp;gt; 1 January 2020&lt;br /&gt;
&lt;br /&gt;
	table.insert (template, author_names_get (raw_iucn_cite));					-- add string of author name parameters&lt;br /&gt;
	table.insert (template, table.concat ({&amp;#039; |year=&amp;#039;, year}));					-- add formatted year&lt;br /&gt;
	local title = title_get (raw_iucn_cite);&lt;br /&gt;
	local errata = title:match (errata_pattern);								-- nil unless IUCN citation has errata annotation; else year that this errata published (|date=)&lt;br /&gt;
	if errata then&lt;br /&gt;
		table.insert (template, table.concat ({&amp;#039; |errata=&amp;#039;, errata}));			-- add formatted errata&lt;br /&gt;
		title = title:gsub (errata_pattern, &amp;#039;&amp;#039;);								-- remove errata annotation&lt;br /&gt;
	end&lt;br /&gt;
	local amends = title:match (amendment_pattern);								-- nil unless IUCN citation has amendment annotation; else year that this assessment amends (|orig-date=)&lt;br /&gt;
	if amends then&lt;br /&gt;
		table.insert (template, table.concat ({&amp;#039; |amends=&amp;#039;, amends}));			-- add year of assessment that this assessment amends&lt;br /&gt;
		title = title:gsub (amendment_pattern, &amp;#039;&amp;#039;);								-- remove amendment annotation&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert (template, title);												-- add formatted title&lt;br /&gt;
	table.insert (template, table.concat ({&amp;#039; |volume=&amp;#039;, volume}));				-- add formatted volume&lt;br /&gt;
	table.insert (template, table.concat ({&amp;#039; |page=&amp;#039;, page}));					-- add formatted page&lt;br /&gt;
	table.insert (template, table.concat ({&amp;#039; |doi=&amp;#039;, doi}));					-- add formatted doi&lt;br /&gt;
	table.insert (template, table.concat ({&amp;#039; |access-date=&amp;#039;, accessdate}));		-- add formatted access-date&lt;br /&gt;
&lt;br /&gt;
	table.insert (template, &amp;#039;}}&amp;#039;);												-- close the template&lt;br /&gt;
&lt;br /&gt;
	if args[2] then																-- if anything in args[2], write a nowiki&amp;#039;d version that editors can copy into &amp;lt;ref&amp;gt; tags&lt;br /&gt;
		return table.concat ({&amp;#039;&amp;lt;code&amp;gt;&amp;#039;, frame:callParserFunction (&amp;#039;#tag:nowiki&amp;#039;, table.concat (template)), &amp;#039;&amp;lt;/code&amp;gt;&amp;#039;})&lt;br /&gt;
	end&lt;br /&gt;
	if args[&amp;#039;ref&amp;#039;] then                                                         -- enable subst of ref tags with name&lt;br /&gt;
		return &amp;#039;&amp;lt;ref name=&amp;#039; .. args[&amp;#039;ref&amp;#039;] .. &amp;#039;&amp;gt;&amp;#039; .. table.concat (template) .. &amp;#039;&amp;lt;/ref&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat (template);												-- the subst&amp;#039;d version&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	cite = cite,&lt;br /&gt;
	make_cite_iucn = make_cite_iucn,&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Tachyony</name></author>
	</entry>
</feed>