Module:Sandbox: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 24: Line 24:
local args = frame.args
local args = frame.args
local tabcontent = args[1]
local tabcontent = args[1]
tabcontent = mw.text.killMarkers(tabcontent)
tabcontent = '\n' .. mw.text.unstripNoWiki(tabcontent) .. '\n'
return tabcontent
return tabcontent
end
end


return p
return p

Latest revision as of 22:19, 16 July 2024

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