Module:In5

-- This module implements.

local p = {}

function p.in5(frame) local indent = frame.args[1] or 5 -- Default to 5. indent = tonumber( mw.text.trim(indent) ) -- Trim whitespace and convert to number. if not indent or indent <= 0 or math.floor(indent) ~= indent then return -- Return blank for zero or bad input. end local base = ' ' local modulo = ' ' --[[   Indent values and the corresponding values for base and modulo:

indent base    modulo 1      0       1    2       0       2    3       1       1    4       1       2    5       2       1    6       2       2    7       3       1    8       3       2    9       4       1    10      4       2 ]]    local baseNum = math.floor( (indent - 1) / 2 ) local modNum = math.fmod( indent - 1, 2 ) + 1 return mw.ustring.rep( base, baseNum) .. mw.ustring.rep( modulo, modNum ) end

return p