--
require('strict')local ext_func_make_tables = require ('Module:Sandbox/trappist the monk/taxonomy').make_tables;local TaxonItalics = require('Module:TaxonItalics') -- use a function from Module:TaxonItalics to italicize a taxon namelocal TableRow = '|- class="taxonrow" \n'local TableEnd = '|}\n'local p = -- functions made publiclocal l = -- internal functions, kept separatelocal colour = -- colour for taxobox and taxonomy listings
--getMaxSearchLevels}}local MaxSearchLevels = 100
function p.getMaxSearchLevels return MaxSearchLevelsend
--taxoboxColour|TAXON}}function p.taxoboxColour(frame) return p.getTaxoboxColour(frame, frame.args[1] or )end
function p.getTaxoboxColour(frame, currTaxon) -- note that colour is global to this function; default is empty string local i = 1 -- count levels processed local searching = currTaxon ~= -- still searching for a colour? local foundICTaxon = false -- record whether 'incertae sedis' found while searching and i <= MaxSearchLevels do local plainCurrTaxon, dummy = l.stripExtra(currTaxon) -- remove trailing text after / if string.lower(plainCurrTaxon)
'rgb' then colour = possibleColour searching = false end end if searching then local ok, parent = p.getTaxonInfoItem(frame, currTaxon, 'parent') if ok and parent ~= then currTaxon = parent i = i + 1 else searching = false -- run off the top of the hierarchy or tried to use non-existent taxonomy template end end end if colour
--= = = = = = = = = = = = = topLevelTaxon = = = = = = = = = = = = = = = = Defines the correct top level taxa, one of which should terminate everytaxonomic hierarchy encoded in taxonomy templates.= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =function l.topLevelTaxon(taxon) return taxon
'Veterovata' or taxon
--taxoboxList|TAXON|display_taxa = the number of taxa *above* TAXON to force to be displayed|authority = taxonomic authority for TAXON|parent_authority = taxonomic authority for TAXON's parent|gparent_authority = taxonomic authority for TAXON's grandparent|ggparent_authority = taxonomic authority for TAXON's greatgrandparent|ggparent_authority = taxonomic authority for TAXON's greatgreatgrandparent|bold_first = 'bold' to bold TAXON in its row|virus = 'yes' to apply virus taxa italicization standards}}function p.taxoboxList(frame) local currTaxon = frame.args[1] or if currTaxon
i, , displayN >= i, , virus) end -- display all taxa above possible parent, with authority if given for i = math.min(topTaxonN, 5), 2, -1 do res = res .. l.showTaxon(frame, taxonTable[i], taxonRankTable[i], topTaxonN
1, authTable[1], true, boldFirst, virus) return resend
--= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =Show one taxon row in a taxobox.= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =function l.showTaxon(frame, taxon, rank, isTopTaxon, auth, force, boldFirst, virus) -- it's an error if this is the top taxon and it's not a top level taxon (e.g. "Life") if isTopTaxon then if l.topLevelTaxon(taxon) then return -- don't display a top level taxon elseif (mw.title.new('Taxonomy/'..taxon, 'Template') or).exists then -- taxonomy template for this taxon has no parent specified return frame:expandTemplate .. '\n' .. TableRow else -- no taxonomy template for this taxon return frame:expandTemplate .. '\n' .. TableRow end else -- if showing is not already forced, force if it's a principal rank or an authority is specified force = force or frame:expandTemplate
'yes' or alwaysDisplay
'bold' then bold = 'yes' end if auth ~= then auth = '
' .. auth .. '' end local res = res .. l.tableCell(l.getTaxonLink(frame, taxon, rank, bold, , , virus) .. auth) -- italic, abbreviated return res .. TableRow else return end endend
--taxonomyList|TAXON}}function p.taxonomyList(frame) local currTaxon = frame.args[1] or if currTaxon