Module:TaxonItalics
Module:TaxonItalics (talk · · hist · links · doc · subpages · sandbox · testcases)
![]() | This Lua module is used on approximately 604,000 pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
Purpose
The module is primarily intended for use by the automated taxobox system. It supports the correct italicization of scientific names. Botanical (ICNafp) names may contain "connecting terms"; these must not be italicized. The hybrid symbol, ×, should also not be italicized. The module optionally wikilinks and abbreviates italicized names.
For non-virus taxa, italics are used at the rank of genus or below. The module does not decide whether a scientific name should be italicized. Use {{Is italic taxon}}
for this purpose.
Usage
- {{#invoke:TaxonItalics|main|TAXON_NAME}} – italicizes a taxon name
- {{#invoke:TaxonItalics|main|TAXON_NAME|linked=yes}} – italicizes a taxon name, wikilinking the italicized output to the unchanged input
- {{#invoke:TaxonItalics|main|TAXON_NAME|abbreviated=yes}} – italicizes a taxon name, abbreviating all but the last part to the first letter
- {{#invoke:TaxonItalics|main|TAXON_NAME|dab=yes}} – italicizes a taxon name, treating any parenthesized part as a disambiguation term, and not italicizing it
The parameters can be combined. It can also be used via {{Taxon italics}}.
Examples
Just italicized
- Connecting terms
- Pinus subg. Pinus → Script error: The function "main" does not exist.
- P. subgenus Pinus → Script error: The function "main" does not exist.
- P. subsect. Pinaster → Script error: The function "main" does not exist.
- Acer tataricum subsp. ginnala → Script error: The function "main" does not exist.
- Aster ericoides var. ericoides → Script error: The function "main" does not exist.
- A. ericoides varietas ericoides → Script error: The function "main" does not exist.
- A. e. subvar. ericoides → Script error: The function "main" does not exist.
Botanical names may contain only one infraspecific epithet; a string like "Fragaria vesca subsp. vesca f. semperflorens" is a classification, not a name, and is not handled by the module.
- Hybrid symbols
- Elaeagnus × submacrophylla → Script error: The function "main" does not exist.
- ×Beallara → Script error: The function "main" does not exist.
- × Beallara → Script error: The function "main" does not exist.
- {{hybrid}}Beallara → Script error: The function "main" does not exist.
Linked
Using |linked=yes
- Populus sect. Aigeiros → Script error: The function "main" does not exist.
- Elaeagnus × submacrophylla → Script error: The function "main" does not exist.
Abbreviated
Using |abbreviated=yes
- Populus sect. Aigeiros → Script error: The function "main" does not exist.
- Acer tataricum subsp. ginnala → Script error: The function "main" does not exist.
- [also linked] × Sorbaronia fallax → Script error: The function "main" does not exist.
- [also linked] Elaeagnus × submacrophylla → Script error: The function "main" does not exist.
- Elaeagnus ×submacrophylla → Script error: The function "main" does not exist.
- Elaeagnus {{hybrid}} submacrophylla → Script error: The function "main" does not exist.
Disambiguation terms
By default, a parenthesized part of a taxon name is assumed to be a subgenus name, and is italicized:
- Varanus (Hapturosaurus) → Script error: The function "main" does not exist.
- Caia (plant) → Script error: The function "main" does not exist. – wrong
To treat a parenthesized part as a disambiguation term, use |dab=yes
- Caia (plant) → Script error: The function "main" does not exist.
- (also linked) Caia (plant) → Script error: The function "main" does not exist.
For even more examples, see the testcases.
local p = {}
--[[=========================================================================
=============================================================================]]
function p.italicizeTaxonName()
local name = frame.args[1] or ''
local result = ''
if name ~= '' then
if string.find(name, "''", 1, true) or string.find(name, "<i>", 1, true) then
result = name
else
local words = mw.text.split(name, " ", true)
if #words ~= 4 then
result = "<i>" .. name .. "</i>"
else
-- need test here for words[3] being connecting term
result = "<i>" .. words[1] .. " " .. words[2] .. "</i> " .. words[3] .. " <i>" .. words[4] .. "</i>"
end
end
end
return result
end
return p