"ഘടകം:TaxonItalics" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
Content deleted Content added
No edit summary |
No edit summary |
||
വരി 2:
--[[=========================================================================
Italicize a taxon name appropriately.
* If the name is already italicized, do nothing.
* If the name is not made up of four words or the name is made up of four
words and the third word is not a botanical connecting term, add italic
markup to the outside of the name.
* If the name is made up of four words and the third word is a botanical
connecting term, add italic markup so as not to italicize the connecting
term.
=============================================================================]]
function p.italicizeTaxonName(frame)
local name = frame.args[1] or ''
-- replace any use of the HTML italic tags by Wikimedia markup
name = string.gsub(string.gsub(name, "<i>", "''"), "</i>", "''")
local result = name
local
if name ~= '' then
if string.sub(name, 1, 2) == "''" then
-- do nothing if the name already
else
local words = mw.text.split(name, " ", true)
if #words ~= 4 then
-- add outside italic markup to names not made up of four words
result =
elseif string.find(name, "''", 1, true) then
-- add outside italic markup to four word names already containing internal italic markup
result =
else
-- test
if words[3] == "subsp." or words[3] == "var." or words[3] == "subvar." or words[3] == "f." or words[3] == "subf." then
-- de-italicize the connecting term by adding internal italic markup
result =
else
-- third word is not a connecting term, so add outside italic markup
result =
end
end
|