Module:ElementTLDFlair: Difference between revisions
IDN flagging fix // via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 41: | Line 41: | ||
-- Build CSS class list | -- Build CSS class list | ||
local classes = { "tld-flair" } | local classes = { "tld-flair" } | ||
-- Add subtype class if present | |||
if subtype ~= "" then | if subtype ~= "" then | ||
local _, css = CanonicalForms.normalize(subtype, template.config.mappings.tld_subtype) | local _, css = CanonicalForms.normalize(subtype, template.config.mappings.tld_subtype) | ||
| Line 47: | Line 49: | ||
end | end | ||
end | end | ||
-- Add IDN class if applicable | |||
if isIDN then | if isIDN then | ||
-- Normalize the type if it hasn't been normalized yet | -- Normalize the type if it hasn't been normalized yet | ||
| Line 56: | Line 60: | ||
local idnClass = (normalizedType == "ccTLD") and "tld-template-idn-cctld" or "tld-template-idn-gtld" | local idnClass = (normalizedType == "ccTLD") and "tld-template-idn-cctld" or "tld-template-idn-gtld" | ||
table.insert(classes, idnClass) | table.insert(classes, idnClass) | ||
-- Otherwise, if no subtype, add base type class for non-IDN TLDs | |||
elseif subtype == "" and tldType ~= "" then | |||
-- Normalize the type if it hasn't been normalized yet | |||
local normalizedType = tldType | |||
if tldType ~= "gTLD" and tldType ~= "ccTLD" then | |||
normalizedType = select(1, CanonicalForms.normalize(tldType, template.config.mappings.tld_type)) or tldType | |||
end | |||
local typeClass = (normalizedType == "ccTLD") and "tld-template-cctld" or "tld-template-gtld" | |||
table.insert(classes, typeClass) | |||
end | end | ||
local classAttr = table.concat(classes, " ") | local classAttr = table.concat(classes, " ") | ||