Module:Outdent
Jump to navigation
Jump to search
Usage[edit source]
Implements {{Outdent}}
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Outdent/doc.
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.outdent (frame)
local args = getArgs(frame)
local width = 0
args['r'] = args['reverse'] or args['indent'] or args['r'] or args['in'] -- aliases for reverse
if not args[1] then args[1] = '' end -- un-nil args[1]
width = width + select(2, string.gsub(args[1],':','')) -- increase by 1 for every :
width = width + select(2, string.gsub(args[1],'*','')) -- increase by 1 for every *
width = width + select(2, string.gsub(args[1],'#','')) * 2 -- increase by 2 for every #
if width == 0 then width = tonumber(args[1]) end -- set width to args[1] if needed
if not width then width = 10 end -- default width
if width < 0
then
width = -width
args['r'] = not args['r']
end
if width > 40 then width = 40 end -- max width
local top = '<span style="' .. (width == 0 and '' or 'border-bottom: 1px dotted var(--content-text-color);') .. 'border-' .. ((width == 0 or args['r']) and 'left' or 'right') ..': 1px dotted var(--content-text-color);"></span>' -- top half
local bottom = '<span style="border-' .. (args['r'] and 'right' or 'left') .. ': 1px dotted var(--content-text-color);"></span>' -- bottom half
local note = args[2] and '<span>([[wp:Indentation#Outdenting|outdent]]) </span>' or '' -- note
return require( 'Module:TSLoader' ).call( 'Module:Outdent/styles.css' ) .. '<div class="outdent-template" style="' .. 'width: calc((1lh + 1px) * ' .. width .. ');">' .. top .. bottom .. note .. '</div>';
end
return p