Module:Sandbox/Johnuniq/unit explained

-- Test the helper function in Module:Convert to get unit information.-- Usage: -- See .

local function collection -- Return a table to hold items. return end

local tests =

local function make_args(text) local flags = local unitcode, options local show = collection show:add('unit(') for item in text:gmatch('%S+') do if unitcode then local k, v k = flags[item] if k then if item

'S' then v = 'on' else v = 'true' end else k = 'value' v = tonumber(item) end if options then show:add(', ') else options = show:add(', ') end show:add(')') return unitcode, options, show:joinend

local function main(frame) local get_unit = require('Module:Convert/sandbox')._unit local results = collection for _, item in ipairs(tests) do local unitcode, options, show = make_args(item) local unit = get_unit(unitcode, options) results:add() results:add('> ' .. show) results:add(string.format('%40s %9s %s', unit.text, unit.unknown and '(unknown)' or , unit.sortspan or )) end return '

\n' .. mw.text.nowiki(results:join('\n')) .. '\n
\n'end

return