"ഘടകം: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 italbeginitalMarker = "''"
local italend = "''"
if name ~= '' then
if string.sub(name, 1, 2) == "''" then
-- do nothing if the name already containshas italic markers at the start
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 = italbeginitalMarker .. name .. italenditalMarker
elseif string.find(name, "''", 1, true) then
-- add outside italic markup to four word names already containing internal italic markup
result = italbeginitalMarker .. name .. italenditalMarker
else
-- test here for words[3]the third word of a four word name being a connecting term
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 = italbeginitalMarker .. words[1] .. " " .. words[2] .. italenditalMarker .. " " .. words[3] .. " " .. italbeginitalMarker .. words[4] .. italenditalMarker
else
-- third word is not a connecting term, so add outside italic markup
result = italbeginitalMarker .. name .. italenditalMarker
end
end
"https://ml.wikipedia.org/wiki/ഘടകം:TaxonItalics" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്