Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Indent
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} function p.indent(frame) -- Trim whitespace from the arguments and remove blank values. local args = {} if type(frame.args) == 'table' then for k, v in pairs( frame.args ) do v = mw.text.trim(v) if v ~= '' then args[k] = v end end end -- Set variables. local indent = tonumber( args[1] ) local br = args[2] local ret = '' -- Insert line breaks to match the functionality of the original template. -- If "br" is set, we need two line breaks; if not, we just need one. if br then ret = ret .. '<br />' end ret = ret .. '<br />' -- Control for bad or zero input. If found, output the line breaks only, -- as this was the previous behaviour of the template. if not indent or indent <= 0 or math.floor(indent) ~= indent then return ret end -- Generate the indents. The first four cases are special. if indent == 1 then return ret .. ' ' elseif indent == 2 then return ret .. ' ' elseif indent == 3 then return ret .. '   ' elseif indent == 4 then return ret .. '   ' end -- Set variables for generating the output after indent == 5. local r = {} r.base = ' ' -- Common text to all output. r.rep = '   ' -- The text to repeat. r.mod1 = ' ' -- To return on modulo 1. r.mod2 = '  ' -- To return on modulo 2. r.mod3 = '   ' -- To return on modulo 3. -- New iteratorText values needed at 5, 9, 13, 17, etc., so repeat the -- text (indent - 1)/4 times and find the remainder. local reps = math.floor( (indent - 1) / 4 ) local remainder = math.fmod( indent - 1, 4 ) -- Generate the indent text. ret = ret .. r.base .. mw.ustring.rep( r.rep, reps ) if remainder >= 1 and remainder <= 3 then ret = ret .. r[ 'mod' .. remainder ] end return ret end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Indent/doc
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)