Editing
Module:TaxonList
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ 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 {{extinct}} β 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 {{extinct}} before it? if (string.sub(taxonName,1,5) == '<abbr') and mw.ustring.find(taxonName, 'β ') then taxonName = string.gsub(taxonName, '^.*</abbr>', '', 1) dagger = 'β ' end end end return taxonName, dagger end --[[========================================================================= The function returns a list of taxon names and authorities, appropriately formatted. Usage: {{#invoke:TaxonList|main |italic = yes - to italicize the taxon name |linked = yes - to wikilink the taxon name |bold = yes - to emboldent the taxon name |incomplete = yes - to output "(incomplete)" at the end of the list }} The template that transcludes the invoking template must supply an indefinite even number of arguments in the format |Name1|Author1 |Name2|Author2| ... |NameN|AuthorN =============================================================================]] function p.main(frame) local italic = frame.args['italic'] == 'yes' local bold = frame.args['bold'] == 'yes' local linked = frame.args['linked'] == 'yes' if bold then linked = false end -- must not have bold and wikilinked local abbreviated = frame.args['abbreviated'] == 'yes' local incomplete = frame.args['incomplete'] == 'yes' local taxonArgs = frame:getParent().args local result = '' -- iterate over unnamed variables local taxonName local dagger local first = true -- is this the first of a taxon name/author pair? for param, value in pairs(taxonArgs) do if tonumber(param) then if first then taxonName = mw.text.trim(value) -- if necessary separate any initial β from the taxon name if linked or italic or bold then taxonName, dagger = p.stripDagger(taxonName) else dagger = '' end if linked and not italic then taxonName = '[[' .. taxonName .. ']]' end if italic then taxonName = TaxonItalics.italicizeTaxonName(taxonName, linked, abbreviated) end if bold then taxonName = '<b>' .. taxonName .. '</b>' end result = result .. '<li>' .. dagger .. taxonName else result = result .. ' <small>' .. value .. '</small></li>' end first = not first end end if incomplete then result = result .. '<small>(incomplete list)</small>' end return '<ul class="taxonlist">' .. result .. '</ul>' end return p
Summary:
Please note that all contributions to MycoTaxa may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
MycoTaxa:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:TaxonList/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information
In other projects