Module:Template input parse: Difference between revisions
Added functions to parse numeric pairs |
m bugfix; comments |
||
Line 72: | Line 72: | ||
-- Delimiter between each pair must be a semicolon | -- Delimiter between each pair must be a semicolon | ||
-- Delimiter between the pair's two values can be anything; default is slash | -- Delimiter between the pair's two values can be anything; default is slash | ||
-- as the intended use is parsing ratios a/b | -- as the intended use is parsing ratios a/b, so input must be formatted as such | ||
-- "a/b; c/d; e/f" | |||
function p.parse_numeric_pairs(unparsed, delimiter) | function p.parse_numeric_pairs(unparsed, delimiter) | ||
local delimiter = delimiter or "/" | local delimiter = delimiter or "/" | ||
Line 82: | Line 83: | ||
local pair = p.parse_numeric_pair(parsed[i], delimiter) | local pair = p.parse_numeric_pair(parsed[i], delimiter) | ||
if pair ~= nil and #pair == 2 then | if pair ~= nil and #pair == 2 then | ||
table.insert(pair) | table.insert(pairs_, pair) | ||
end | end | ||
end | end |