Module:Sandbox

Revision as of 22:19, 16 July 2024 by Rman41 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/doc

local getArgument = require('Module:Arguments').getArgument

local p = {}

function trim(s) -- Allows removing of whitespace and line breaks from inputs; adapted from (https://www.lua.org/manual/2.4/node32.html)
	local l = 1
	while string.sub(s,l,l) == ' ' do
	l = l+1
	end
	while string.sub(s,l,l+1) == '\n' do
	l = l+2
	end
	local r = string.len(s)
	while string.sub(s,r,r) == ' ' do
	r = r-1
	end
	while string.sub(s,r,r-1) == '\n' do
	r = r-2
	end
	return string.sub(s,l,r)
end

function p.Main(frame)
	local args = frame.args
	local tabcontent = args[1]
	tabcontent = '\n' .. mw.text.unstripNoWiki(tabcontent) .. '\n'
	return tabcontent
end

return p