"ഘടകം:TaxonItalics" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

Content deleted Content added
No edit summary
No edit summary
വരി 1:
--[[=========================================================================
Italicize a taxon name appropriately by invoking italicizeTaxonName.
The rulesalgorithm used areis:
* If the name has italic markup at the start or the end, do nothing.
* Else
* Else if the name is made up of four words and the third word is a
botanical* connectingRemove term, add(internal) italic markup to the outside of the name and.
* Else if* If the name is made up of four words and the third word is a
de-italicize the connecting term.
botanical connecting term or a variant of "cf.", add italic markup to the outside of the name and
* Else if the name is made up of three words and the second word is a
de-italicize the connecting term.
botanical connecting term or a variant of "cf.", add italic markup to the
outside* ofElse if the name andis de-italicizemade up of three words and the connectingsecond word is term.a
botanical connecting term or a variant of "cf.", add italic markup to the
* Else do nothing.
outside of the name and de-italicize the connecting term.
-- add outside* Else add italic markup to namesthe not made upoutside of fourthe wordsname.
=============================================================================]]
 
Line 51 ⟶ 53:
-- trim the name and replace any use of the HTML italic tags by Wikimedia markup
name = string.gsub(string.gsub(mw.text.trim(name), "<i>", "''"), "</i>", "''")
local result = name
local italMarker = "''"
local result = name
if name ~= '' then
if string.sub(name, 1, 2) == "''" or string.sub(name, -2) == "''" then
Line 60 ⟶ 62:
local words = mw.text.split(name, " ", true)
if #words == 4 then
-- test for the third word of a four word name being a connecting term
if string.find(name, "''", 1, true) then
if cTerms3[words[3]] then
-- add outside italic markup to four word names already containing internal italic markup
-- de-italicize the connecting term by adding internal italic markup
result = italMarker .. name .. italMarker
result = italMarker .. words[1] .. " " .. words[2] .. italMarker .. " " .. cTerms3[words[3]] .. " "italMarker .. italMarker" " .. words[4] .. italMarker
else
-- test for the third word of a four word name being a connecting term
if cTerms3[words[3]] then
-- de-italicize the connecting term by adding internal italic markup
result = italMarker .. words[1] .. " " .. words[2] .. italMarker .. " " .. cTerms3[words[3]] .. " " .. italMarker .. words[4] .. italMarker
else
-- third word is not a connecting term, so add outside italic markup
result = italMarker .. name .. italMarker
end
end
elseif #words == 3 then
-- test for the second word of a three word name being a connecting term
if string.find(name, "''", 1, true) then
if cTerms2[words[2]] then
-- add outside italic markup to three word names already containing internal italic markup
-- third word is notde-italicize athe connecting term, soby addadding outsideinternal italic markup
result = italMarker .. name .. italMarker
result = words[1] .. " " .. italMarker .. namecTerms2[words[2]] .. italMarker .. " " .. words[3]
else
-- test for the second word of a three word name being a connecting term
if cTerms2[words[2]] then
-- de-italicize the connecting term by adding internal italic markup
result = italMarker .. words[1] .. " " .. italMarker .. cTerms2[words[2]] .. " " .. italMarker .. words[3] .. italMarker
else
-- second word is not a connecting term, so add outside italic markup
result = italMarker .. name .. italMarker
end
end
else
* Else -- do nothing.
-- add outside italic markup to names not made up of four words
result = italMarker .. name .. italMarker
end
-- add outside markup
result = italMarker .. nameresult .. italMarker
end
end
"https://ml.wikipedia.org/wiki/ഘടകം:TaxonItalics" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്