Jump to content

Module:Sandbox/BrandonXLF/4

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by BrandonXLF (talk | contribs) at 04:27, 18 April 2024. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- Sandbox, do not delete
local p = {}

function p.main(frame)
	local wikitext = frame:preprocess(frame.args[1])
	local items = {}
	
	for indent, item in wikitext:gmatch("(**) *([^\n]+)") do  
	    items[#items + 1] = {indent, item}
	end
	
	for i, item in pairs(items) do  
		if i < #items and #items[i + 1][1] > #item[1] then
			item[2] = "'''''" .. item[2] .. "'''''"
		end
	end
	
	local out = ''
	
	for _, item in pairs(items) do
    	out = out .. item[1] .. item[2] .. '\n'
    end
	
	return out
end

return p