Module:ListGeneration: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- | --[[ | ||
* Name: ListGeneration | |||
* Author: Mark W. Datysgeld | |||
* Description: Centralized and flexible module for generating various types of lists from delimited strings, designed to replace fragmented list generation logic | |||
* Notes: Handles semicolon-delimited strings automatically; supports multiple list modes (bullet, bullet_custom, invisible, comma); allows custom CSS classes on list container; provides itemHook for custom per-item processing and formatting; accepts both string input (auto-split) and pre-split table input | |||
]] | |||
- | |||
- | |||
local p = {} | local p = {} | ||
| Line 52: | Line 34: | ||
local items | local items | ||
if type(input) == 'string' then | if type(input) == 'string' then | ||
items = NormalizationText.splitMultiValueString(input) | -- Default to splitting only by semicolon. This is a safer default than also splitting by "and", which can break up valid entity names. | ||
-- Callers that need more complex splitting logic should pre-split the string and pass a table instead. | |||
local semicolonOnlyPattern = {{pattern = ";%s*", replacement = ";"}} | |||
items = NormalizationText.splitMultiValueString(input, semicolonOnlyPattern) | |||
else | else | ||
items = input | items = input | ||