Модуль:Taxonomy/latin

Материал из GreenWiki
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:Taxonomy/latin/doc

local p = {}

local ZooKursiv = "/Вид/Род/Подвид/Подрод/Ихновид/Ихнород/Комплекс видов/Форма/"

function p.latin(frame)
    local latin = frame.args[1]
    if string.find(latin, "'", 1, true) then
        return latin
    elseif latin == "incertae sedis" then
        return "''incertae sedis''"
    elseif string.find(latin, "^Candidatus") then
       latin = string.gsub(latin, "^Candidatus", "''%0''", 1)
       return latin
    end

    local regnum = frame.args["regnum"]
    local rang = frame.args["rang"] or ""
    local srang = "/" .. rang .. "/"    

    local italic = ((regnum ~= "Животные") and (regnum ~= "Простейшие") or string.find(ZooKursiv, srang, 1, true))

    if italic then
        latin = string.gsub(latin, "%l+%.", "''%0''")
        if (regnum == "Бактерии") or (regnum == "Археи") then
            latin = string.gsub(latin, "%s+%u[%u%d%p]*$", "''%0''")
        end
        latin = string.gsub("''" .. latin .. "''", "''''", "")
    end
    return latin
end

function p.author(frame)
	local author= frame.args[1]
        if string.find(author, "%set al%.") then
        author = string.gsub(author, "(%[*%set al%.%]*)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%sex%s") then
        author = string.gsub(author, "(%sex%s)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%set%s") then
        author = string.gsub(author, "(%set%s)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%sin%s") then
        author = string.gsub(author, "(%sin%s)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%semend%.") then
        author = string.gsub(author, "(%semend%.)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%sapud%s") then
        author = string.gsub(author, "(%sapud%s)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%se%. a%.") then
        author = string.gsub(author, "(%[*%se%. a%.%]*)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "hort%.") then
        author = string.gsub(author, "(%[*hort%.%]*)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "auct%.") then
        author = string.gsub(author, "(%[*auct%.%]*%s?%a*%.?%]*)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "nom%.") then
        author = string.gsub(author, "(%[*nom%. %a+%.%]*)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "corrig%.") then
        author = string.gsub(author, "(corrig%.)", "<span style='font-variant:normal;'>%1</span>")
        end
        if string.find(author, "%sand%s") then
        author = string.gsub(author, "(%sand%s)", "<span style='font-variant:normal;'>%1</span>")
        end
return "<span style='font-variant:small-caps;'>" .. author .. "</span>"
end

return p