Module:Flagg: Difference between revisions

Content deleted Content added
implement a and p options
Copy from sandbox
 
(10 intermediate revisions by 2 users not shown)
Line 172:
am = am.."|"..am
end
 
--Build display name
local text = args["text"]
Line 185:
if mn == "*" and clink ~= flink then
text = text:sub(1, -3) .. "\226\128\175*]]" end
elseif msmn=="l" then --linedisplay breaklink target
text = flink=="" and name or "[["..flink..fsec.."|"..(args["name"] or flink).."]]"
elseif mn=="b" then --both prefix/suffix and normal country link
local preflink = pref and (flink=="" and pref.." " or "[["..flink..fsec.."|"..pref.."]] ") or ""
Line 201 ⟶ 203:
text = name
elseif mn=="a" then --abbr
text = name==country and (clink==namecountry and namecountry or "<abbr title='"..clink.."'>"..country.."</abbr>") or ("<abbr title='"..name.."'>"..country.."</abbr>")
else --country link (default)
text = clink=="" and name or "[["..clink..csec.."|"..name.."]]"
Line 214 ⟶ 216:
end
 
--Define separator
local separator = "&nbsp;"
elseif if ms=="lx" then --lineno breakseparator
separator = ""
elseif ms=="nl" then --non-breakingline spacebreak
separator = "<br />"
end
--Add preftext, if used
local preftext = args["preftext"]
if (preftext or "") ~= "" then
text = preftext..separator..text
end
--Build image
local ilink = args["ilink"]
Line 246 ⟶ 262:
 
if iname==placeholder then
if require('Module:yesno')(args["noredlink"]) == false or args["noredlink"] == "notext" then
if country ~= '' and data.alias == nil then
iname = ''
iname = ''
image = "[[:Template:Country data "..country.."]]"
if args["noredlink"] == "notext" then
iname text = ''
end
end
end
if (args["missingcategory"] or '') ~= '' then
Line 267 ⟶ 288:
if (ms=="x" and mi=="x") or (string.find(me,"o") and iname==placeholder and pimage~=placeholder) then --name only
out = text
elseif ms=="x" or ms=="n" or ms=="l" then --no separator, non-breaking space, or line break
out = text.."<span class=\"flagicon nowrap\">"..separator..image.."</span>"
elseif ms=="n" then --non-breaking space
out = text.."<span class=\"flagicon\">&nbsp;"..image.."</span>"
elseif ms=="l" then --line break
out = text.."<span class=\"flagicon\"><br/>"..image.."</span>"
elseif ms=="t" then --table cell
out = "style=\"text-align:"..(nalign or "left").."\"|"..text.."||style=\"text-align:"..(align or "center").."\"|<span class=\"flagicon\">"..image.."</span>"
else --fixed-width span box (default)
local width = args["width"] or args["w"] or require("Module:Flaglist").luawidth(size)
out = text.."<span class=\"nowrap\">&nbsp;<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "right").."\">"..image.."</span></span>"
end
else --image left of name
if (ms=="x" and mi=="x") or (string.find(me,"o") and iname==placeholder and pimage~=placeholder) then --name only
out = text
elseif ms=="x" or ms=="n" or ms=="l" then --no separator, non-breaking space, or line break
out = "<span class=\"flagicon\">"..image..separator.."</span>"..text
elseif ms=="n" then --non-breaking space
out = "<span class=\"flagicon\">"..image.."&nbsp;</span>"..text
elseif ms=="l" then --line break
out = "<span class=\"flagicon\">"..image.."<br/></span>"..text
elseif ms=="t" then --table cell
out = "style=\"text-align:"..(align or "center")..";\"|<span class=\"flagicon\">"..image.."</span>||style=\"text-align:"..(nalign or "left").."\"|"..text
else --fixed-width span box (default)
local width = nopx(args["width"] or args["w"]) or require("Module:Flaglist").luawidth(size)
out = "<span class=\"nowrap\"><span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "left").."\">"..image.."</span>&nbsp;</span>"..text
end
end
if string.find(me,"w") then --avoid wrapping
out = "<span class=\"nowrap\">"..out.."</span>"
end
Line 313 ⟶ 323:
 
end
 
p[''] = p.main
 
return p