Modul:TaxonItalics: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Dari WP:EN.
 
kTidak ada ringkasan suntingan
 
Baris 21:
 
local p = {}
local l = {} -- used to store purely local functions
 
--connecting terms in three part names (e.g. Pinus sylvestris var. sylvestris)
Baris 53 ⟶ 54:
["subg."] = "subg.",
subg = "subg.",
--supersect.
supersection = "supersect.",
["supersect."] = "supersect.",
supersect = "supersect.",
--sect.
section = "sect.",
Baris 86 ⟶ 91:
 
--[[=========================================================================
Utility local function to abbreviate an input string to its first character
followed by ".".
Both "×" and an HTML entity at the start of the string are skipped over in
determining first character, as is an opening parenthesis, whichand causesan aopening ",
which cause a matching closing parenthesischaracter to be included.
=============================================================================]]
function pl.abbreviate(str)
local result = ""
local hasParentheses = false
local isQuoted = false
if mw.ustring.len(str) < 2 then
--single character strings are left unchanged
Baris 103 ⟶ 109:
hasParentheses = true
result = "("
str = mw.ustring.sub(str,2,mw.ustring.len(str))
elseif mw.ustring.sub(str,1,1) == '"' then
isQuoted = true
result = '"'
str = mw.ustring.sub(str,2,mw.ustring.len(str))
end
Baris 117 ⟶ 127:
end
--if there's anything left, reduce it to its first character plus ".",
--adding the closing parenthesis or quote if required
if str ~= "" then
result = result .. mw.ustring.sub(str,1,1) .. "."
if hasParentheses then result = result .. ")" end
elseif isQuoted then result = result .. '"'
end
end
end
Baris 152 ⟶ 164:
words[3] = '<span style="font-style:normal;">' .. cTerms3[words[3]] .. '</span>'
if abbreviated then
words[1] = pl.abbreviate(words[1])
words[2] = pl.abbreviate(words[2])
end
result = words[1] .. " " .. words[2] .. " " .. words[3] .. " " .. words[4]
Baris 161 ⟶ 173:
words[2] = '<span style="font-style:normal;">' .. cTerms2[words[2]] .. '</span>'
if abbreviated then
words[1] = pl.abbreviate(words[1])
end
result = words[1] .. " " .. words[2] .. " " .. words[3]
Baris 168 ⟶ 180:
if abbreviated then
if #words > 1 then
result = pl.abbreviate(words[1])
for i = 2, #words-1, 1 do
result = result .. " " .. pl.abbreviate(words[i])
end
result = result .. " " .. words[#words]
Baris 182 ⟶ 194:
-- deal with any parentheses as they should not be italicized
result = string.gsub(string.gsub(result,"%(",'<span style="font-style:normal;">(</span>'),"%)",'<span style="font-style:normal;">)</span>')
-- any question marks surrounded by spans can have the spans joined
-- add outside markup
result = string.gsub(result,'</span>%?<span style="font%-style:normal;">','?')
-- add outside markup
if linked then
if result ~= name then