Jump to content

Module:Test: Difference between revisions

From Marxist Wiki
Created page with "local p = {} function p.test( frame ) -- Get contents of page local pageContent = tostring(mw.title.getCurrentTitle():getContent()) -- Split contents of page in lines local pageLines = mw.text.split(pageContent,'\n',true) local render = '' for i=1,#pageLines do -- Get every line starting with '==', that is, a header if mw.text.split(pageLines[i], '%s')[1] == '==' then render = render .. pageLines[i] end end return render end return p"
 
m Protected "Module:Test" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
(No difference)

Latest revision as of 02:20, 13 March 2025

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

local p = {}
function p.test( frame )
	-- Get contents of page
	local pageContent = tostring(mw.title.getCurrentTitle():getContent())
	-- Split contents of page in lines
	local pageLines = mw.text.split(pageContent,'\n',true)
	local render = ''
	for i=1,#pageLines do
		-- Get every line starting with '==', that is, a header
		if mw.text.split(pageLines[i], '%s')[1] == '==' then
			render = render .. pageLines[i]
		end
	end
	return render
end
return p