Module:NormalizationText: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- | --[[ | ||
* Name: NormalizationText | |||
* Author: Mark W. Datysgeld | |||
* Description: Centralized text normalization module for standardizing text formats with comprehensive processing capabilities | |||
* Notes: String normalization (case, whitespace, punctuation); wiki link processing; multi-value string handling; user input sanitization with pattern categories; extensive caching for performance; supports custom patterns and delimiter handling | |||
]] | |||
local p = {} | local p = {} | ||
-- Dependencies | |||
local LinkParser = require('Module:LinkParser') | |||
-- Module-level caches | -- Module-level caches | ||
local functionCache = {} | local functionCache = {} | ||
-- Pattern categories for sanitizing user input | -- Pattern categories for sanitizing user input | ||
| Line 20: | Line 20: | ||
pattern = "%[%[([^|%]]+)%]%]", | pattern = "%[%[([^|%]]+)%]%]", | ||
replacement = function(match) | replacement = function(match) | ||
return | return LinkParser.processWikiLink("[[" .. match .. "]]", "strip") | ||
end | end | ||
}, | }, | ||
| Line 26: | Line 26: | ||
pattern = "%[%[([^|%]]+)|([^%]]+)%]%]", | pattern = "%[%[([^|%]]+)|([^%]]+)%]%]", | ||
replacement = function(match1, match2) | replacement = function(match1, match2) | ||
return | return LinkParser.processWikiLink("[[" .. match1 .. "|" .. match2 .. "]]", "strip") | ||
end | end | ||
} | } | ||
| Line 120: | Line 120: | ||
end | end | ||
-- Sanitizes user input by removing unwanted patterns | -- Sanitizes user input by removing unwanted patterns | ||