Module:Inventory slot: Difference between revisions

Add support for custom hex code colors
No edit summary
(Add support for custom hex code colors)
 
(8 intermediate revisions by the same user not shown)
Line 170: Line 170:
end
end
else
else
if mw.title.new(link).exists == false then
if mw.title.new(name).exists == false then
link = i18n.modLink:gsub( '%$1', 'mcwiki' ):gsub( '%$2', name )
link = i18n.modLink:gsub( '%$1', 'mcwiki' ):gsub( '%$2', name )
else
else
Line 193: Line 193:
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' )
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' )
local formatPattern = '&[0-9a-fk-or]'
local formatPatterns = {'&[0-9a-jl-qs-vyzr]', '&#%x%x%x%x%x%x', '&$%x%x%x'}
if plainTitle:match( formatPattern ) then
for _, formatPattern in ipairs( formatPatterns ) do
formattedTitle = title
if plainTitle:match( formatPattern ) then
plainTitle = plainTitle:gsub( formatPattern, '' )
formattedTitle = title
plainTitle = plainTitle:gsub( formatPattern, '' )
end
end
end
Undo