Jump to content

Module:Taxobox ranks

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Peter coxhead (talk | contribs) at 11:08, 7 May 2025 (Peter coxhead moved page Module:Sandbox/Peter coxhead/Taxobox ranks to Module:Taxobox ranks without leaving a redirect: ready for testing in main space before release). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

--[[*************************************************************************
This module provides support to the automated taxobox system – the templates
Automatic taxobox, Speciesbox, Subspeciesbox, Infraspeciesbox, etc.

In particular it is part of the configuration of the system, defining the
rank names that are recognized and the way they are displayed in English in
taxoboxes and viewed taxonomy templates.
*****************************************************************************]]
require('strict')

local Autotaxobox = require('Module:Autotaxobox/sandbox') -- use a function from Module:Autotaxobox
local TableRow = '|-\n'
local TableEnd = '|}\n'
local p = {} -- functions made public
local l = {} -- internal functions, kept separate

--[[************************** CONFIGURATION ********************************
Set up a constant to hold the rank names and their English equivalents.
If adding to this list, note that rank names containing spaces or - must be
enclosed in [' '].
*****************************************************************************]]
local ranks =
	{
		--Special cases, alphabetic order
		alliance = '<i>Alliance</i>',
		['basic shell type'] = '<i>Basic shell type</i>',
		branch = '<i>Branch</i>',
		clade = '<i>Clade</i>',
		cladus= '<i>Clade</i>',
		['form taxon'] = '<i>Form taxon</i>',
		grade = '<i>Grade</i>',
		gradus = '<i>Grade</i>',
		informal = '<i>Informal group</i>',
		['informal group'] = '<i>Informal group</i>',
		morphotype = '<i>Morphotype</i>',
		node = '<i>Node</i>',
		plesion = '<i>Plesion</i>',
		['plesion-group'] = '<i>Plesion-group</i>',
		['possible clade'] = '<i>Clade?</i>',
		['species complex'] = '<i>Species complex</i>',
		['species group'] = '<i>Species group</i>',
		['species subgroup'] = '<i>Species subgroup</i>',
		['stem group'] = '<i>Stem group</i>',
		['total group'] = '<i>Total group</i>',
		--Special virus ranks
		realm = 'Realm',
		serotype = 'Serotype',
		strain = 'Strain',
		virus = 'Virus',
		['virus group'] = 'Group',
		--Linnaean taxonomy, alphabetic order
		classis = 'Class',
		cohort = 'Cohort',
		divisio = 'Division',
		domain = 'Domain',
		epifamilia = 'Epifamily',
		familia = 'Family',
		forma = 'Form',
		genus = 'Genus',
		grandordo = 'Grandorder',
		['grandordo-mb'] = 'Grandorder', --McKenna & Bell version
		hyperfamilia = 'Hyperfamily',
		infraclassis = 'Infraclass',
		infralegio = 'Infralegion',
		infralegion = 'Infralegion',
		infraordo = 'Infraorder',
		infraphylum = 'Infraphylum',
		infraregnum = 'Infrakingdom',
		infratribus = 'Infratribe',
		legio = 'Legion',
		legion = 'Legion',
		magnordo = 'Magnorder',
		micrordo = 'Microrder',
		microphylum = 'Microphylum',
		mirordo = 'Mirorder',
		['mirordo-mb'] = 'Mirorder', --McKenna & Bell version
		nanordo = 'Nanorder',
		nanophylum = 'Nanophylum',
		ordo = 'Order',
		parafamilia = 'Parafamily',
		parvclassis = 'Parvclass',
		parvordo = 'Parvorder',
		phylum = 'Phylum',
		regnum = 'Kingdom',
		sectio = 'Section',
		series = 'Series',
		species = 'Species',
		subclassis = 'Subclass',
		subcohort = 'Subcohort',
		subdivisio = 'Subdivision',
		subfamilia = 'Subfamily',
		subgenus = 'Subgenus',
		sublegio = 'Sublegion',
		sublegion = 'Sublegion',
		subordo = 'Suborder',
		subphylum = 'Subphylum',
		subregnum = 'Subkingdom',
		subsectio = 'Subsection',
		subseries = 'Subseries',
		subspecies = 'Subspecies',
		subterclassis = 'Subterclass', --used in WoRMS
		subtribus = 'Subtribe',
		superclassis = 'Superclass',
		supercohort = 'Supercohort',
		superdivisio = 'Superdivision',
		superdomain = 'Superdomain',
		superfamilia = 'Superfamily',
		superlegio = 'Superlegion',
		superlegion = 'Superlegion',
		superordo = 'Superorder',
		superphylum = 'Superphylum',
		superregnum = 'Superkingdom',
		supersectio = 'Supersection',
		supertribus = 'Supertribe',
		tribus = 'Tribe',
		varietas = 'Variety',
		zoodivisio = 'Division',
		zoosectio = 'Section',
		zooseries = 'Series',
		zoosubdivisio = 'Subdivision',
		zoosubsectio = 'Subsection',
		--trace fossil taxonomy, alphabetic order-->',
		ichnoclassis = 'Ichnoclass',
		ichnocohort = 'Ichnocohort',
		ichnodivisio = 'Ichnodivision',
		ichnofamilia = 'Ichnofamily',
		ichnogenus = 'Ichnogenus',
		ichnograndordo = 'Ichnograndorder',
		['ichnograndordo-mb'] = 'Ichnograndorder', --McKenna & Bell version
		ichnoinfraclassis = 'Ichnoinfraclass',
		ichnoinfradivisio = 'Ichnoinfradivision',
		ichnoinfraordo = 'Ichnoinfraorder',
		ichnolegio = 'Ichnolegion',
		ichnolegion = 'Ichnolegion',
		ichnomagnordo = 'Ichnomagnorder',
		ichnomicrordo = 'Ichnomicrorder',
		ichnoordo = 'Ichnoorder',
		ichnoparvordo = 'Ichnoparvorder',
		ichnospecies = 'Ichnospecies',
		['ichnostem-group'] = 'Ichnostem-Group',
		ichnosubclassis = 'Ichnosubclass',
		ichnosubdivisio = 'Ichnosubdivision',
		ichnosubfamilia = 'Ichnosubfamily',
		ichnosublegio = 'Ichnosublegion',
		ichnosublegion = 'Ichnosublegion',
		ichnosubordo = 'Ichnosuborder',
		ichnosuperclassis = 'Ichnosuperclass',
		ichnosupercohort = 'Ichnosupercohort',
		ichnosuperfamilia = 'Ichnosuperfamily',
		ichnosuperordo = 'Ichnosuperorder',
		--fossilized egg taxonomy, alphabetic order
		ooclassis = 'Ooclass',
		oocohort = 'Oocohort',
		oofamilia = 'Oofamily',
		oogenus = 'Oogenus',
		oomagnordo = 'Oomagnorder',
		oordo = 'Oorder',
		oospecies = 'Oospecies',
		oosubclassis = 'Oosubclass',
		oosubgenus = 'Oosubgenus',
		oosubspecies = 'Oosubspecies',
		oosupercohort = 'Oosupercohort',
		oosuperordo = 'Oosuperorder',
	}
	
--[[======================== angliciseRank ==================================
Returns the English language equivalent of a rank name used in a taxonomy
template.
If the rank name is not in the table of ranks, then the first letter
of the rank name is capitalized and used as the English name.
If checked=yes, then the generated English name is highlighted in red. If
called from a taxonomy template, the page is put in
Category:Taxonomy templates using capitalized rank parameters
=============================================================================]]
function p.angliciseRank(frame)
	local rankName = frame.args[1]
	local check = frame.args['check'] or 'no'
	rankName = string.gsub(rankName, '_', ' ') -- replace all underscores by spaces
	if string.sub(rankName, 1,8) == 'unranked' then return '(unranked)' end
	local res = ranks[rankName]
	if res then return res
	else
		--rankName is not in the table of recognized ranks; ensure 1st letter is capitalized
		res = string.upper(string.sub(rankName,1,1)) .. string.sub(rankName,2)
		if check == 'no' then return res
		else
			res = '<span style="background-color:#F99">' .. res .. '</span>' 
			local pageTitle =  mw.title.getCurrentTitle()
			if pageTitle.nsText == 'Template' and pageTitle.rootText == 'Taxonomy' then
				res = res .. '[[Category:Taxonomy templates using capitalized rank parameters]]'
			end
			return res
		end
	end 
end

--[[========================== showRanks ====================================
Returns a wikitable showing all the recognized ranks, how they are shown in
taxoboxes, whether they are automatically italicized, and whether they are
checked for consistency of rank order.
Usage: {{#invoke:Taxobox ranks|showRanks}}
=============================================================================]]
function p.showRanks(frame)
	local res = '{| class="wikitable sortable"\n'
	res = res ..'|+ Ranks recognized in taxonomy templates\n'
	res = res .. '!style="text-align: left;"|Rank name in<br/>taxonomy<br/>template'
	res = res .. '!!style="text-align: left;"|Shown in<br/>taxobox as'
	res = res .. '!! style="text-align: left;" |Taxon name<br/>automatically<br/>italicized?'
	res = res .. '!! style="text-align: left;" |Rank checked<br/>for consistent<br/>order?'
	res = res .. '\n'
	for k, t in pairs(ranks) do
		res = res .. TableRow .. '|' .. k .. '||' .. t .. '||' .. frame:expandTemplate{ title = 'Is italic taxon', args = { k } } .. '||' .. Autotaxobox.hasRankVal1(k) .. '\n'
	end
	return res .. TableEnd
end

return p