Module:TaxonItalics and Module:TaxonItalics/sandbox: Difference between pages

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
imported>Peter coxhead
updated to tested sandbox version; adds "dab" parameter
 
imported>Artoria2e5
Restored revision 1149257954 by Lemondoge (talk): Wrong page!!
 
Line 154: Line 154:
     name = mw.text.trim(name)
     name = mw.text.trim(name)
     -- if the name begins with '[', then assume formatting is present
     -- if the name begins with '[', then assume formatting is present
     if mw.ustring.sub(name,1,1) == '[' then return name end
     if mw.ustring.sub(name,1,1) == '[' then return name end
     -- otherwise begin by replacing any use of the HTML italic tags
     -- otherwise begin by replacing any use of the HTML italic tags
     -- by Wikimedia markup; replace any entity alternatives to the hybrid symbol
     -- by Wikimedia markup; replace any entity alternatives to the hybrid symbol
Line 189: Line 189:
                 end
                 end
                 result = words[1] .. " " .. words[2] .. " " .. words[3]
                 result = words[1] .. " " .. words[2] .. " " .. words[3]
             else
             elseif abbreviated then -- not a name as above; only deal with abbreviation
                -- not a name as above; only deal with abbreviation
                 if #words > 1 then
                 if abbreviated then
                result = l.abbreviate(words[1])
                if #words > 1 then
                for i = 2, #words-1, 1 do
                result = l.abbreviate(words[1])
                result = result .. " " .. l.abbreviate(words[i])
                for i = 2, #words-1, 1 do
                result = result .. " " .. l.abbreviate(words[i])
                end
                result = result .. " " .. words[#words]
                 end
                 end
                else
                 result = result .. " " .. words[#words]
                 result = name
                 end
                 end
            else
                result = name
             end
             end
             -- deal with any hybrid symbol as it should not be italicized
             -- deal with any hybrid symbol as it should not be italicized
Line 238: Line 235:
function p.hasConnectingTerm(name)
function p.hasConnectingTerm(name)
local words = mw.text.split(name, " ", true)
local words = mw.text.split(name, " ", true)
if #words == 4 and cTerms3[words[3]] then return true
return (#words == 4 and cTerms3[words[3]])
elseif #words == 3 and cTerms2[words[2]] then return true
or (#words == 3 and cTerms2[words[2]])
else return false
end
end
end
return p
return p