Module:User:JeffDoozan/taxlink

Hello, you have come here looking for the meaning of the word Module:User:JeffDoozan/taxlink. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:JeffDoozan/taxlink, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:JeffDoozan/taxlink in singular and plural. Everything you need to know about the word Module:User:JeffDoozan/taxlink you have here. The definition of the word Module:User:JeffDoozan/taxlink will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:JeffDoozan/taxlink, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

function format_text(text, rank, force_italics)

    if force_italics then
        return "''" .. text .. "''"
    end

    if rank == "nothogenus"
        or rank == "subgenus"
        or rank == "subg."
        or rank == "genus"
        or rank == "subsection"
        or rank == "section"
        or rank == "subsect."
        or rank == "sect."
        or rank == "nothospecies"
        or rank == "infraspecies"
        or rank == "subspecies"
        or rank == "subsp."
        or rank == "species"
        or rank == "variety"
        or rank == "var."
        or rank == "forma"
        or rank == "form"
        or rank == "morph"
        or rank == "morpha"
        or rank == "species group"
        or rank == "cultivar"
        or rank == "cvar."
        or rank == "series"
        or rank == "ser."
    then
        text = require("Module:italics").i(text)
    end
    return text
end

function format_result(target, rank, text, cats, warning)
    -- Don't create categories for entries on User: pages
    if cats ~= "" and mw.title.getCurrentTitle().nsText == "User" then
        cats = ""
    end

    if warning ~= "" then
        warning = '<sup class="error previewonly"><small>' .. warning .. '</small></sup>'
    end

    return '<span class="biota">' .. ']' .. warning .. cats .. '</span>'
end


function export.taxlink(frame)
    local warn = ""
    local cats = ""

	local params = {
		 = {required = true},
		 = {required = true},
		 = {},
		 = {type = "boolean"},
		 = {type = "boolean"},
		 = {},
		 = {},
		 = {},
	}
	local args, invalid_args = require("Module:parameters").process(frame:getParent().args, params, "return unknown")

    if next(invalid_args) then
--        cats = cats .. "]"
		-- ]
		local track = require("Module:debug/track")
		track("bad_params/taxlink")

		for k, v in pairs(invalid_args) do
		    if warn ~= "" then warn = warn .. "; " end
		    warn = warn .. "unexpected parameter: " .. k .. "=" .. v

			-- ]
			track("bad_params/taxlink/" .. k)
		end
	end

    local taxon = args or ""
    local rank = args or ""
    local text = args or taxon
    text = format_text(text, rank, args)

    local target
    -- if page exists and nomul= is not set, use a local link and add to cleanup category
    if (not args) and mw.title.new( taxon ):getContent() ~= nil then
        cats = cats .. "]"
        target = taxon .. "#Translingual"
        if warn ~= "" then warn = warn .. "; " end
        warn = warn .. "(Please check if this is already defined at target. Replace <code>{{]}}</code> with a regular link if already defined. Add nomul=1 if not defined.)"
    else
		-- undocumented and unused in existing entries as of 2/24/2024, if rank is epithet use local link
		if rank == "epithet" then
		    target = taxon .. "#Translingual"

		else
		    if args then
		        if args == "0" then
		            target = "w:" .. taxon
		        elseif args == "1" then
		            target = "w:" .. mw.title.getCurrentTitle().subpageText
		        else
		            target = "w:" .. args
		        end
		    else
		        if args then
		            target = "Wikispecies:" .. args
		        else
		            target = "Wikispecies:" .. taxon
		        end
		    end
		end
    end

    if not args then
        label = rank and rank or "unknown"
        cats = cats .. "]"
    end

    return format_result(target, rank, text, cats, warn)
end

function export.taxfmt(frame)
    local warn = ""

	local params = {
		 = {required = true},
		 = {required = true},
		 = {},
		 = {type = "boolean"},

        -- unused parameters, allowed for easy renaming {{taxlink}} to {{taxfmt}}
		 = {type = "boolean"},
		 = {},
		 = {},
		 = {},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)

    local taxon = args or ""
    local rank = args or ""
    local text = args or taxon
    text = format_text(text, rank, args)

    local target = taxon .. "#Translingual"

    return format_result(target, rank, text, "", warn)
end


return export