Jump to content

Module:TaxonItalics

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Peter coxhead (talk | contribs) at 09:23, 8 February 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

--[[=========================================================================
=============================================================================]]
function p.italicizeTaxonName(frame)
	local name = frame.args[1] or ''
	local result = name
	if name ~= '' then
		if string.find(name, "''", 1, true) or string.find(name, "<i>", 1, true) then
			-- do nothing if already contains italic markers
		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
				if words[3] == "subsp." then
					result = "<i>" .. words[1] .. " " .. words[2] .. "</i> " .. words[3] .. " <i>" .. words[4] .. "</i>"
				else
					result = "<i>" .. name .. "</i>"
				end
			end
		end
	end
	return result
end

return p