Difference between revisions of "Module:Outdent"

From Summertime Saga Wiki
Jump to: navigation, search
m
m
Line 24: Line 24:
 
width = width * 1.6 -- set width to proper width
 
width = width * 1.6 -- set width to proper width
 
 
local top = '<span style="display:block;width:' .. width .. 'em;height:0.5em;' .. (width == 0 and '' or 'border-bottom:1px solid #AAA;') .. 'border-' .. ((width == 0 or args['r']) and 'left' or 'right') ..':1px solid #AAA;"></span>' -- top half
+
local top = '<span style="display:block; width:' .. width .. 'em; height:0.5em;' .. (width == 0 and '' or 'border-bottom:thin solid #AAA; ') .. 'border-' .. ((width == 0) and 'left' or 'right') ..':thin solid #AAA;"></span>' -- top half
local bottom = '<span style="display:block;width:' .. width .. 'em;height:0.5em;border-' .. (args['r'] and 'right' or 'left') .. ':1px solid #AAA;"></span>' -- bottom half
+
local bottom = '<span style="display:block;width:' .. width .. 'em; height:0.5em; border-' .. ('right' or 'left') .. ':thin solid #AAA;"></span>' -- bottom half
 
local note = args[2] and '<span>([[Wikipedia:Indentation#Outdenting|outdent]])&#32;</span>' or '' -- note
 
local note = args[2] and '<span>([[Wikipedia:Indentation#Outdenting|outdent]])&#32;</span>' or '' -- note
 
 
return '<div class="outdent-template" style="position:relative;left:1px;">' .. top .. bottom .. note .. '</div>';
+
return '<div class="outdent-template" style="position:relative; left:1px; ">' .. top .. bottom .. note .. '</div>';
 
end
 
end
  
 
return p
 
return p

Revision as of 00:26, 11 July 2020

Implements {{outdent}}.


local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.outdent (frame) 
	local args = getArgs(frame)
	local width = 0
	
	args[1] = ''
	
	width = width + select(2, string.gsub(args[1],':',''))
	width = width + select(2, string.gsub(args[1],'*',''))
	width = width + select(2, string.gsub(args[1],'#','')) * 2
	
	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
	
	width = width * 1.6															-- set width to proper width
	
	local top = '<span style="display:block; width:' .. width .. 'em; height:0.5em;' .. (width == 0 and '' or 'border-bottom:thin solid #AAA; ') .. 'border-' .. ((width == 0) and 'left' or 'right') ..':thin solid #AAA;"></span>' -- top half
	local bottom = '<span style="display:block;width:' .. width .. 'em; height:0.5em; border-' .. ('right' or 'left') .. ':thin solid #AAA;"></span>' -- bottom half
	local note = args[2] and '<span>([[Wikipedia:Indentation#Outdenting|outdent]])&#32;</span>' or '' -- note
	
	return '<div class="outdent-template" style="position:relative; left:1px; ">' .. top .. bottom .. note .. '</div>';
end

return p