Module:TaxonList
Wikimedia module / From Wikipedia, the free encyclopedia
--[[ This module provides the core functionality to a set of templates used to display a list of taxon name/authority pairs, with the taxon names optionally italicized, wikilinked and/or emboldened. Such lists are usually part of taxoboxes. ]]
-- use a function from Module:TaxonItalics to italicize a taxon name local TaxonItalics = require("Module:TaxonItalics")
local p = {}
--[[========================================================================= Utility function to strip off any initial † present to mark the taxon as extinct. The † must not be italicized, emboldened, or included in the wikilinked text, so needs to be added back afterwards. † is assumed to be present as one of: * the unicode character † * the HTML entity † * the output of † – this will have been expanded before reaching this module and is assumed to have the form '<span ... </span>' The function returns two values: the taxon name with any † before it removed and either '†' if it was present or the empty string if not. =============================================================================]] function p.stripDagger(taxonName) local dagger = if mw.ustring.sub(taxonName,1,1) == '†' then taxonName = mw.ustring.sub(taxonName,2,#taxonName) dagger = '†' else if string.sub(taxonName,1,8) == '†' then taxonName = string.sub(taxonName,9,#taxonName) dagger = '†' else -- did the taxon name originally have † before it? if (string.sub(taxonName,1,5) == '<span') and mw.ustring.find(taxonName, '†') then taxonName = string.gsub(taxonName, '^.*', , 1) dagger = '†' end end end return taxonName, dagger end
--[[========================================================================= The function returns a list of taxon names and authorities, appropriately formatted. Usage:
result = result .. '
' end first = not first end end if incomplete then result = result .. '(incomplete list)' end return '
- ' .. result .. '
'
end
return p