Modul:Autotaxobox: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Perbarui sintaks LUA per versi terbaru dari modul yang bersangkutan. |
Hidayatsrf (bicara | kontrib) Tidak ada ringkasan suntingan |
||
Baris 1:
--[[*************************************************************************
This module provides support to the automated taxobox system – the templates
Automatic taxobox, Speciesbox, Subspeciesbox, Infraspeciesbox, etc.
Baris 5:
In particular it provides a way of traversing the taxonomic hierarchy encoded
in taxonomy templates (templates with names of the form
"Template:Taxonomy/TAXON_NAME") without causing template expansion depth
errors. *****************************************************************************]]
require('Module:No globals')
local TaxonItalics = require('Module:TaxonItalics') -- use a function from Module:TaxonItalics to italicize a taxon name
local
local TableEnd = '|}\n'
local p = {} -- functions made public
local l = {} -- internal functions, kept separate
local colour = '' -- colour for taxobox and taxonomy listings
--[[=========================================================================
Baris 15 ⟶ 21:
avoids excessive processing time and protects against incorrectly set up
hierarchies, e.g. loops.
The value can be obtained externally via
{{#invoke:Autotaxobox|getMaxSearchLevels}}
=============================================================================]]
local MaxSearchLevels = 100
Baris 33 ⟶ 41:
=============================================================================]]
function p.taxoboxColour(frame)
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 =
if string.lower(plainCurrTaxon) == 'incertae sedis' then
foundICTaxon = true
Baris 59 ⟶ 70:
end
end
if colour
if foundICTaxon then
colour = frame:expandTemplate{ title = 'Template:Taxobox colour', args = { 'incertae sedis' } }
elseif searching then
-- hierarchy exceeds MaxSearchLevels levels
colour = frame:expandTemplate{ title = 'Template:Taxobox/Error colour', args = { } }
else
colour = 'transparent'
end
end
return colour
end
--[[= = = = = = = = = = = = = topLevelTaxon = = = = = = = = = = = = = = = =
Defines the correct top level taxa, one of which should terminate every
taxonomic hierarchy encoded in taxonomy templates.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.topLevelTaxon(taxon)
return taxon == 'Life' or taxon == 'Veterovata' or taxon == 'Ichnos'
end
Baris 88 ⟶ 108:
function p.taxoboxList(frame)
local currTaxon = frame.args[1] or ''
if currTaxon == '' then return '' end
local displayN = (tonumber(frame.args['display_taxa']) or 1) + 1
local
authTable[5] = frame.args['gggparent_authority'] or ''
local boldFirst = frame.args['bold_first'] or 'link' -- values 'link' or 'bold'
local virus = frame.args['virus'] or 'no' -- values 'yes' or 'no'
local
-- adjust the authority table if 'authority' refers to a rank lower than the target taxon
if offset ~= 0 then
for i = 1, 5 do
local j = i + offset
if j <= 5 then
authTable[i] = authTable[j]
else
authTable[i] = ''
end
end
end
local taxonTable, taxonRankTable = l.makeTable(frame, currTaxon)
local res = ''
local topTaxonN = taxonTable.n
-- display all taxa above possible greatgreatgrandparent, without authority
for i = topTaxonN, 6, -1 do
res = res .. l.showTaxon(frame, taxonTable[i], taxonRankTable[i], topTaxonN==i, '', displayN >= i, '', virus)
end
-- display
for i = math.min(topTaxonN, 5), 2, -1 do
res = res .. l.showTaxon(frame
end
-- display target taxon, always displayed and emboldened
res = res .. l.showTaxon(frame, taxonTable[1], taxonRankTable[1], topTaxonN==1, authTable[1], true, boldFirst, virus)
return res
end
--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
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').exists then
-- taxonomy template for this taxon has no parent specified
return frame:expandTemplate{ title = 'Template:Create taxonomy', args = {taxon, msg='Taxonomy template does not specify a parent'} } .. '\n' .. TableRow
else
-- no taxonomy template for this taxon
return frame:expandTemplate{ title = 'Template:Create taxonomy', args = {taxon, msg='Missing taxonomy template'} } .. '\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{ title = 'Template:Principal rank', args = {rank} } == 'yes' or
auth ~= ''
if not force then
-- if showing is still not already forced, force if the taxonomy template has 'always_display' set
local ok, alwaysDisplay = p.getTaxonInfoItem(frame, taxon, 'always_display')
force = alwaysDisplay == 'yes' or alwaysDisplay == 'true'
end
if force then
local res = l.tableCell(frame:expandTemplate{ title = 'Template:Anglicise rank', args = {rank} } .. ':')
local bold = 'no'
if boldFirst == 'bold' then bold = 'yes' end
if auth ~= '' then
auth = '<br><small>' .. auth .. '</small>'
end
local res = res .. l.tableCell(l.getTaxonLink(frame, taxon, rank, bold, '', '', virus) .. auth) -- italic, abbreviated
return res .. TableRow
else
return ''
end
end
end
Baris 135 ⟶ 192:
function p.taxonomyList(frame)
local currTaxon = frame.args[1] or ''
if currTaxon == '' then
return '{|class="infobox biota"\n' .. TableRow .. l.tableCell('') .. l.tableCell('ERROR: no taxon supplied') .. TableEnd
end
local taxonTable, taxonRankTable = l.makeTable(frame, currTaxon)
local rankValTable = l.getRankTable()
local lastRankVal = 1000000
local orderOk = true
-- check whether the taxonomy is for viruses; use already determined taxon colour if possible
local virus = 'no'
local taxoColour = colour
if taxoColour == '' then
if taxonTable[taxonTable.n] == 'Ichnos' or taxonTable[taxonTable.n] == 'Veterovata' then
taxoColour = frame:expandTemplate{ title = 'Template:Taxobox colour', args = { taxonTable[taxonTable.n] } }
else
taxoColour = frame:expandTemplate{ title = 'Template:Taxobox colour', args = { taxonTable[taxonTable.n - 1] } }
end
end
if taxoColour == frame:expandTemplate{ title = 'Template:Taxobox colour', args = { 'virus' } } then
virus = 'yes'
end
-- add information message
local res = '<p style="float:right">Bold ranks show taxa that will be shown in taxoboxes<br>because rank is principal or <code>always_display=yes</code>.</p>\n'
-- start table
res = res .. '{| class="infobox biota" style="text-align: left; font-size:100%"\n' .. TableRow .. '! colspan=4 style="text-align: center; background-color: '
.. taxoColour .. '"|Ancestral taxa\n'
-- deal first with the top level taxon; if there are no errors, it should be Life/Veterovata/Ichnos, which are
-- not displayed
local taxon = taxonTable[taxonTable.n]
if not l.topLevelTaxon(taxon) then
local msg = 'Taxonomy template missing'
if mw.title.new('Taxonomy/'..taxon, 'Template').exists then
msg = 'Parent taxon needed'
end
res = res .. TableRow .. l.tableCell('colspan=2', frame:expandTemplate{title = 'Template:Create taxonomy', args = {taxon, msg = msg}})
end
-- now output the rest of the table
local currRankVal
for i = taxonTable.n-1, 1, -1 do
-- check ranks are in right order in the hierarchy
local
currRankVal = l.lookupRankVal(rankValTable, rank)
if currRankVal then
orderOk = currRankVal < lastRankVal
Baris 150 ⟶ 240:
else
orderOk = true
end
-- see if the row will be displayed in a taxobox; bold the rank if so
local boldRank = false
local ok, alwaysDisplay = p.getTaxonInfoItem(frame, taxon, 'always_display')
if ok and (alwaysDisplay == 'yes' or alwaysDisplay == 'true') then
boldRank = true
else
boldRank = frame:expandTemplate{ title = 'Template:Principal rank', args = {rank} } == 'yes'
end
-- now return a row of the taxonomy table with anomalous ranks marked
local errorStr = ''
if not orderOk then errorStr = '
local link = l.getTaxonLink(frame, taxon, rank, '', '', '', virus) -- bold, italic, abbreviated
res = res .. l.taxonomyListRow(frame, taxon, rank, link, boldRank, errorStr)
end
-- close table
res = res .. TableEnd
-- error-tracking for taxonomy templates
-- if the last row has an anomalous rank, put the page in an error-tracking category
local errCat1 = ''
if not orderOk then
end
-- if the last row has a taxon name in the page name that does not match the link text,
-- put the taxonomy template in a tracking category
local dummy, linkText = p.getTaxonInfoItem(frame, taxon, 'link_text')
local match = l.matchTaxonLink(taxon, linkText, currRankVal and currRankVal < rankValTable['genus'])
local errCat2 = ''
if not match then
errCat2 = '[[Category:Taxonomy templates with name and link text not matching|' .. taxon .. ']]\n'
end
if errCat1..errCat2 ~= '' then
res = res .. frame:expandTemplate{ title = 'Template other', args = { errCat1..errCat2} }
end
return res
end
--[[ = = = = = = = = = = = = = = taxonomyListRow = = = = = = = = = = = = = =
Returns a single row of the taxonomy table displayed on the right hand side
of "Template:Taxonomy...." pages.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.taxonomyListRow(frame, taxon, rank, link, boldRank, error)
local res = ''
if taxon == '' or rank == '' then return res end
local baseTaxon, qualifier = l.stripExtra(taxon)
-- if appropriate, make it clear that some taxa have been skipped via a ... row
if qualifier == '/skip' then
res = res .. TableRow .. l.tableCell('.....') .. l.tableCell('.....')
end
-- now generate a row of the table
res = res .. TableRow
local cellContent = ''
local anglicizedRank = frame:expandTemplate{ title = 'Template:Anglicise rank', args = { rank } }
if boldRank then
cellContent = cellContent .. '<b>' .. anglicizedRank .. '</b>:'
else
cellContent = cellContent .. anglicizedRank .. ':'
end
if error == 'yes' then
cellContent = '<span style="background-color:#FDD">' .. cellContent .. '</span>'
end
res = res .. l.tableCell(cellContent)
.. l.tableCell('<span style="white-space:nowrap;">' .. link .. '</span>')
.. l.tableCell('<span style="font-size:smaller;">' .. qualifier .. '</span>')
.. l.tableCell('<span style="white-space:nowrap;">' .. frame:expandTemplate{ title = 'Template:Edit a taxon', args = { taxon } } .. '</span>')
return res
end
Baris 179 ⟶ 323:
}}
=============================================================================]]
local PARENT = 1
local RANK = 2
Baris 186 ⟶ 329:
local ALWAYS_DISPLAY = 5
local EXTINCT = 6
local SAME_AS = 7
local REFS = 8
function p.callTaxonomyKey(frame)
local taxon = frame.args['taxon'] or ''
local parent = frame.args['parent'] or ''
local rank = frame.args['rank'] or ''
Baris 220 ⟶ 365:
local link = linkTarget
if linkText ~= '' and linkText ~= linkTarget then link = link .. "|" .. linkText end
-- check consistency of extinct status; if this taxon is not extinct, parent must not be either
local extinctError = 'no'
if parent ~= '' and (extinct == '' or extinct == 'no' or extinct == 'false') then
local ok, parentExtinct = p.getTaxonInfoItem(frame, parent, 'extinct')
if ok and (parentExtinct == 'yes' or parentExtinct == 'true') then extinctError = 'yes' end
end
return frame:expandTemplate{ title = 'Template:Taxonomy key',
args = {taxon=taxon, parent=parent, rank=rank, extinct=extinct, always_display=alwaysDisplay, link_target=linkTarget, link=link, refs=refs, same_as=sameAsTaxon, extinct_error = extinctError} }
end
--[[============================= showRefs ==================================
Shows the refs field in a taxonomy template, handing incertae sedis taxa and
using '–' for absent refs.
Usage: {{#invoke:Autotaxobox|showRefs|TAXON|REFS}}
=============================================================================]]
function p.showRefs(frame)
local taxonName = frame.args[1] or ''
local refs = frame.args[2] or ''
return l.doShowRefs(taxonName, refs)
end
--[[= = = = = = = = = = = = = = doShowRefs = = = = = = = = = = = = = = = = =
Show the refs field in a taxonomy template.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.doShowRefs(taxonName, refs)
if mw.text.split(taxonName, '/', true)[1] == 'Incertae sedis' then
refs = 'not applicable (<i>incertae sedis</i>)'
elseif refs == '' then
refs = '–'
end
return refs
end
Baris 228 ⟶ 402:
one 'same as' link if required.
Usage: {{#invoke:Autotaxobox|taxonInfo|TAXON|ITEM}}
ITEM is one of: 'parent', 'rank', 'link target', 'link text
'always display', 'refs', 'same as' or 'all'.
If ITEM is not specified, the default is 'all' – all values in a single string
Baris 239 ⟶ 413:
local ok, info = p.getTaxonInfoItem(frame, taxon, item)
return info
end
--[[= = = = = = = = = = = getTaxonInfoItem = = = = = = = = = = = = = = = = =
Utility function to extract an item of information from a
taxonomy template, following one 'same as' link if required.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function p.getTaxonInfoItem(frame, taxon, item)
local ok, info
-- item == 'dagger' is a special case
if item == 'dagger' then
ok, info = p.getTaxonInfoItem(frame, taxon, 'extinct')
if ok then
if info == 'yes' or info == 'true' then
info = '†'
else
info = ''
end
end
-- item ~= 'dagger'
else
ok, info = pcall(frame.expandTemplate, frame, { title = 'Template:Taxonomy/' .. taxon, args = {['machine code'] = item } })
if ok then
if info == '' then
-- try 'same as'
local sameAsTaxon = frame:expandTemplate{ title = 'Template:Taxonomy/' .. taxon, args = {['machine code'] = 'same as' } }
if sameAsTaxon ~= '' then
ok, info = pcall(frame.expandTemplate, frame, { title = 'Template:Taxonomy/' .. sameAsTaxon, args = {['machine code'] = item } })
end
end
end
end
if ok then
-- if item is 'link_text', trim info and check whether '(?)' needs to be added
if item == 'link_text' then
-- there is a newline at the end of linkText when taxonomy template has "|link = LINK_TARGET|LINK_TEXT"
info = mw.text.trim(info)
if string.sub(taxon, -2) == '/?' and not string.find(info, '?', 1, true) then
info = info .. '<span style="font-style:normal;font-weight:normal;"> (?)</span>'
end
end
else
info = '[[Template:Taxonomy/' .. taxon .. ']]' --error indicator in code before conversion to Lua
end
return ok, info
end
Baris 251 ⟶ 469:
|italic= : 'yes' makes the core output italic
|link_target= : target for the wikilink
|link_text= : text of the wikilink (may be same as link_target), without †, italics, etc.
}}
=============================================================================]]
Baris 259 ⟶ 477:
local bold = frame.args['bold'] or ''
local italic = frame.args['italic'] or ''
local abbreviated = frame.args['abbreviated'] or ''
local linkTarget = frame.args['link_target'] or ''
local linkText = frame.args['link_text'] or frame.args['plain_link_text'] or '' --temporarily allow alternative args
return l.makeLink(taxon, extinct, bold, italic, abbreviated, linkTarget, linkText)
end
--[[= = = = = = = = = = = = = = getTaxonLink = = = = = = = = = = = = = = = =
Internal function to drive l.makeLink().
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.getTaxonLink(frame, taxon, rank, bold, italic, abbreviated, virus)
local ok, extinct = p.getTaxonInfoItem(frame, taxon, 'extinct')
if italic == '' then
italic = frame:expandTemplate{ title = 'Template:Is italic taxon', args = { rank, virus = virus } }
end
local ok, linkTarget = p.getTaxonInfoItem(frame, taxon, 'link_target')
local ok, linkText = p.getTaxonInfoItem(frame, taxon, 'link_text')
return l.makeLink(taxon, extinct, bold, italic, abbreviated, linkTarget, linkText)
end
--[[= = = = = = = = = = = = = = makeLink = = = = = = = = = = = = = = = = = =
Actually make the link.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.makeLink(taxon, extinct, bold, italic, abbreviated, linkTarget, linkText)
local dummy
-- if link text is missing, try to find a replacement
if linkText == '' then
Baris 267 ⟶ 507:
linkTarget = 'Incertae sedis'
else
linkText, dummy =
end
end
if linkTarget == '' then linkTarget = linkText end
if italic == 'yes' then linkText = TaxonItalics.italicizeTaxonName(linkText, false, abbreviated=='yes') end
local link = ''
if bold == 'yes' then link = '<b>' .. linkText .. '</b>'
Baris 294 ⟶ 534:
Usage: {{#invoke:Autotaxobox|showRankTable}}
=============================================================================]]
function p.showRankTable(frame)
local rankTable =
local res = '{| class="wikitable sortable"\n|+ Ranks checked in taxonomy templates\n! Rank !! Shown as !! Value\n'
for k, v in pairs(rankTable) do
local rankShown = frame:expandTemplate{ title = 'Template:Anglicise rank', args = { k } }
res = res ..
end
return res ..
end
Baris 309 ⟶ 548:
Usage: {{#invoke:Autotaxobox|find|TAXON|RANK}}
=============================================================================]]
function p.find(frame)
local currTaxon = frame.args[1] or ''
Baris 397 ⟶ 635:
local currTaxon = frame.args[1] or ''
if currTaxon == '' then return 'ERROR: no taxon supplied' end
return
end
function l.doListAll(taxonTable, taxonRankTable)
local lst = taxonTable[1] .. '-' .. tostring(taxonRankTable[1])
for i = 2, taxonTable.n, 1 do
lst = lst .. ', ' .. taxonTable[i] .. '-' .. taxonRankTable[i]
end
return lst
end
--[[=========================== removeQualifier ================================
External utility function to remove a qualifier (any part after a "/") from a
taxon name.
Usage: {{#invoke:Autotaxobox|removeQualifier|TAXON}}
=============================================================================]]
function p.removeQualifier(frame)
local baseName, qualifier = l.stripExtra(frame.args[1])
return baseName
end
Baris 404 ⟶ 660:
=============================================================================]]
--[[= = = = = = = = = = = =
Internal utility function to strip off any extra parts of a taxon name, i.e.
anything after a '/'. Thus
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function
local i =
if i then
return
else
return taxonName, ''
end
end
--[[= = = = = = = = = = = =
Internal utility function to
them. Possible formats include:
* taxon
* taxon (disambig)
* taxon (Subgenus)
* taxon/qualifier
* combinations, e.g. taxon (disambig)/qualifier
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function
-- get any qualifier present
local qualifier = ''
local i = mw.ustring.find(taxon, '/', 1, true)
if i then
qualifier = mw.ustring.sub(taxon, i+1, -1)
taxon = mw.ustring.sub(taxon, 1, i-1)
end
-- get any disambiguator or subgenus
local disambig = ''
local subgenus = ''
i = mw.ustring.find(taxon, ' (', 1, true)
if i then
local parenTerm = mw.ustring.sub(taxon, i+2, -2)
taxon = mw.ustring.sub(taxon, 1, i-1)
local char1 = mw.ustring.sub(parenTerm, 1, 1)
if char1 == mw.ustring.lower(char1) then
disambig = parenTerm
else
subgenus = parenTerm
end
end
return taxon, disambig, subgenus, qualifier
end
--[[= = = = = = = = = = = = matchTaxonLink = = = = = = = = = = = = = = = = =
Function to determine whether the taxon name derived from the name of the
taxonomy template (passed in the parameter taxon) matches the link text
(passed in the parameter linkText).
The taxon name may have any of the formats:
* baseTaxon/qualifier
* baseTaxon (disambig)
* baseTaxon (Subgenus) [distinguished by the capital letter]
* a qualifier may be present after the previous two formats.
Examples of matches (baseTaxon ~ linkText):
* Pinus ~ Pinus
* Pinus sect. Trifoliae ~ Pinus sect. Trifoliae
* Pinus sect. Trifoliae ~ ''Pinus'' sect. ''Trifoliae'' [italic markers ignored]
* Pinus sect. Trifoliae ~ P. sect. Trifoliae [abbreviated genus name matches]
* Bombus (Pyrobombus) ~ Bombus (Pyrobombus)
* Bombus (Pyrobombus) ~ B. (Pyrobombus)
* Bombus (Pyrobombus) ~ Pyrobombus [link text may just be the subgenus]
* Heteractinida ~ "Heteractinida" [double-quotes are ignored in link text]
* "Heteractinida" ~ Heteractinida [double-quotes are ignored in base taxon name]
* Incertae sedis ~ anything [link text is ignored for matching in this case]
* Cetotheriidae with qualifier=? ~ Cetotheriidae (?)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.matchTaxonLink(taxon, linkText, rankBelowGenus)
local dummy
linkText, dummy = mw.ustring.gsub(linkText, "''", '') -- remove any italic wikitext in the link text
linkText, dummy = mw.ustring.gsub(linkText, '<.->', '') -- strip all tags used to format the link text
linkText, dummy = mw.ustring.gsub(linkText, '"', '') -- remove any occurrences of " in the link text
local baseTaxon, disambig, subgenus, qualifier = l.splitTaxonName(taxon) -- split up the taxon name
baseTaxon, dummy = mw.ustring.gsub(linkText, '"', '') -- remove any occurrences of " in the base taxon name
local match = linkText == baseTaxon or
linkText == subgenus or
linkText == baseTaxon .. ' (' .. subgenus .. ')' or
linkText == mw.ustring.sub(baseTaxon, 1, 1) .. '. (' .. subgenus .. ')' or
baseTaxon == 'Incertae sedis' or
rankBelowGenus and linkText == mw.ustring.gsub(baseTaxon, '([A-Z]).- (.*)', '%1. %2') or
mw.ustring.find(qualifier, '?', 1, true) and mw.ustring.find(linkText, baseTaxon, 1, true) == 1
return match
end
--[[= = = = = = = = = = = = =
Internal utility function to return a table (array) constructed from a
taxonomic hierarchy stored in "Template:Taxonomy/..." templates.
TABLE.n holds the total number of taxa; TABLE[1]..TABLE[TABLE.n] the taxon
names.
The last taxon in the table will either (a) have a taxonomy template but with
no parent given (e.g. 'Life') or (b) not have a taxonomy template.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function
local taxonTable = {}
local taxonRankTable = {}
local ok, rank, parent
local i = 1
local
repeat
ok, rank = p.getTaxonInfoItem(frame, currTaxon, 'rank')
if ok then taxonRankTable[i] = string.lower(rank) else taxonRankTable[i] = '' end
ok, parent = p.getTaxonInfoItem(frame, currTaxon, 'parent')
if ok and parent ~= '' then
currTaxon = parent
i = i + 1
else
end
until topReached or i > MaxSearchLevels
taxonTable.n = math.min(i, MaxSearchLevels)
return taxonTable, taxonRankTable
end
--[[= = = = = = = = = = = =
Internal utility function to set up a table of numerical values corresponding
to 'Linnaean' ranks, with upper ranks having higher values. In a valid
Baris 520 ⟶ 785:
The ranks should correspond to those in Template:Anglicise ranks.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function
return {
classis = 1400,
Baris 531 ⟶ 796:
grandordo = 1005,
['grandordo-mb'] = 1002,
hyperfamilia = 805;
infraclassis = 1397,
infralegio = 1197,
Baris 584 ⟶ 850:
zoosubsectio = 898,
}
end
--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Function to look up the arbitrary numerical value of a rank in a rank value
table. "Ichno" and "oo" ranks are not stored separately, so if present the
prefix is removed.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.lookupRankVal(rankValTable, rank)
local rankVal = rankValTable[rank]
if not rankVal then
-- may be an "ichno" or "oo" ranks
rank = mw.ustring.gsub(mw.ustring.gsub(rank, '^ichno', ''), '^oo', '')
if rank == 'rdo' then rank = 'ordo' end
rankVal = rankValTable[rank]
end
return rankVal
end
--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.tableCell(arg1, arg2)
local text, style
if arg2 then
style = arg1
text = arg2
else
style = ''
text = arg1
end
local res = '|'
if style ~= '' then
res = res .. style .. '|'
end
return res .. text .. '\n'
end
|