More actions
Skycrafter (talk | contribs) No edit summary |
Skycrafter (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
-- Module:Deformat | -- Module:Deformat | ||
-- Removes dollar-sign based formatting codes from a string. | -- Removes dollar-sign based formatting codes from a string. | ||
local p = {} | local p = {} | ||
function p.run(frame) | function p.run(frame) | ||
local text = frame.args[1] or '' | local text = frame.args[1] or '' | ||
if | if text == '' then return '' end | ||
local | local s = text | ||
s = mw.ustring.gsub(s, '%$%$', '$') | |||
s = mw.ustring.gsub(s, '%$%x%x%x?', '') | |||
s = mw.ustring.gsub(s, '%$[lh]%[[^%]]*%]', '') | |||
s = mw.ustring.gsub(s, '%$[lh]%[', '') | |||
s = mw.ustring.gsub(s, '%$.', '') | |||
return | return s | ||
end | end | ||
return p | return p |
Latest revision as of 22:27, 20 August 2025
Documentation for this module may be created at Module:Deformat/doc
-- Module:Deformat
-- Removes dollar-sign based formatting codes from a string.
local p = {}
function p.run(frame)
local text = frame.args[1] or ''
if text == '' then return '' end
local s = text
s = mw.ustring.gsub(s, '%$%$', '$')
s = mw.ustring.gsub(s, '%$%x%x%x?', '')
s = mw.ustring.gsub(s, '%$[lh]%[[^%]]*%]', '')
s = mw.ustring.gsub(s, '%$[lh]%[', '')
s = mw.ustring.gsub(s, '%$.', '')
return s
end
return p