Module:Percent
Jump to navigation
Jump to search
Documentation The documentation below is transcluded from Module:Percent/doc. (edit | history)
This module provides functionality to the {{percent}}
template.
return {
format = function(frame)
local str = frame.args[1]
local format = frame.args[2]
local dec = frame.args[3]
-- the characters in the pattern are:
-- digit (%d), period (.), hyphen (-), en dash (–), minus (−), plus (+)
str = mw.ustring.gsub(str, '([%d.-–−+][%s%d.-–−+]*)%s*%%', function(s)
s = mw.text.trim(s)
s = string.gsub(s, '%.', dec)
s = string.gsub(format, '%$percentage%$', s)
return s
end)
return str
end,
}