Module:TemplateHelpers: Difference between revisions
// via Wikitext Extension for VSCode Tag: Reverted |
// via Wikitext Extension for VSCode Tag: Manual revert |
||
| Line 272: | Line 272: | ||
-- Normalization Wrappers | -- Normalization Wrappers | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Formats website URLs as an HTML unordered list of links, ensuring consistent emoji display | |||
-- Uses the centralized ListGeneration module. | |||
function p.normalizeWebsites(value) | |||
if not value or value == "" then return "" end | |||
local ListGeneration = require('Module:ListGeneration') | |||
-- Define the item hook for website-specific formatting | |||
local function websiteItemHook(site) | |||
-- Ensure the site has a protocol prefix for proper linking | |||
local linkUrl = site | |||
if not linkUrl:match("^%a+://") then | |||
linkUrl = "https://" .. linkUrl | |||
end | |||
-- The hook returns the content of the li tag, which is the formatted link | |||
return string.format("[%s %s]", linkUrl, linkParser.strip(site)) | |||
end | |||
-- Set the options for the list generation | |||
local options = { | |||
mode = 'bullet', | |||
listClass = 'template-list-website', | |||
itemHook = websiteItemHook | |||
} | |||
return ListGeneration.createList(value, options) | |||
end | |||
-- Wrapper around CountryData for consistent country formatting | -- Wrapper around CountryData for consistent country formatting | ||