Module:Outdent

-- This module implements

local cfg = {}

-- -- Configuration --

cfg.defaultLevel = 10 cfg.outdentLink = 'outdent'

-- -- Load external modules --

local mArguments = require('Module:Arguments')

-- -- Main functions --

local p = {}

function p.main(frame) local args = mArguments.getArgs(frame) local outdent = args[1] local showLink = args[2] return p._main(outdent, showLink) end

function p._main(outdent, showLink) local width = p.calculateWidth(outdent) local link = p.getLink(showLink) return p.export(width, link) end

function p.calculateWidth(outdent) local outdentNum = tonumber(outdent) local outdentLevel if outdentNum then outdentLevel = outdentNum elseif type(outdent) == 'string' then local startOffset, endOffset = outdent:find('^:*$') if endOffset then outdentLevel = endOffset else outdentLevel = defaultLevel end else outdentLevel = defaultLevel end outdentLevel = math.floor(outdentLevel) if outdentLevel < 1 then outdentLevel = defaultLevel end local width = outdentLevel * 1.6 - 0.8 return width end

function p.getLink(showLink) if showLink then return string.format('(%s) ', cfg.outdentLink) else return '' end end

function p.export(width, link) local ret = ' ' .. ' ┌ '		.. '' .. '────────────────────────────────────────────────────────────────────────────────────────────────────'		.. ' '		.. ' ┘ '		.. ' '		.. link return ret end

return p