Module:Outdent: Difference between revisions
More actions
mNo edit summary |
mNo edit summary |
||
| Line 6: | Line 6: | ||
local width = 0 | 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],'*','')) | width = width + select(2, string.gsub(args[1],'*','')) | ||
width = width + select(2, string.gsub(args[1],'#','')) * 2 | 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 width == 0 then width = tonumber(args[1]) end -- set width to args[1] if needed | ||
Revision as of 22:21, 10 July 2020
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 = '' -- top half local bottom = '' -- bottom half local note = args[2] and '(outdent) ' or -- note
return '
';
end
return p