Module:TemplateHelpers: Difference between revisions
// via Wikitext Extension for VSCode Tag: Manual revert |
// via Wikitext Extension for VSCode |
||
| Line 273: | Line 273: | ||
-- Formats website URLs as an HTML unordered list of links, ensuring consistent emoji display | -- Formats website URLs as an HTML unordered list of links, ensuring consistent emoji display | ||
-- Uses | -- Uses the centralized ListGeneration module. | ||
function p.normalizeWebsites(value) | function p.normalizeWebsites(value) | ||
if not value or value == "" then return "" end | if not value or value == "" then return "" end | ||
local ListGeneration = require('Module:ListGeneration') | |||
local | |||
-- 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 | end | ||
return string.format(" | -- The hook returns the content of the li tag, which is the formatted link | ||
return string.format("[%s %s]", linkUrl, linkParser.strip(site)) | |||
end | end | ||
return | -- Set the options for the list generation | ||
local options = { | |||
mode = 'bullet', | |||
listClass = 'template-list-website', | |||
itemHook = websiteItemHook | |||
} | |||
return ListGeneration.createList(value, options) | |||
end | end | ||