Content deleted Content added
|
|
end
return res .. '|}\n'
end
function p.find(frame)
local currTaxon = frame.args[1] or ''
if currTaxon == '' then return 'ERROR: no taxon supplied' end
local rank = frame.args[2] or ''
if rank == '' then return 'ERROR: no rank supplied' end
local inHierarchy = true -- still in the taxonomic hierarchy or off the top?
local searching = true -- still searching
while inHierarchy and searching do
local ok, parent = p.getTaxonInfoItem(frame, currTaxon, 'parent')
if ok and parent ~= '' then
currTaxon = parent
if p.getTaxonInfoItem(frame, currTaxon, 'rank') == rank then
searching = false
end
else
inHierarchy = false
end
end
if inHierarchy and not searching then return currTaxon
else return ''
end
end
|