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 06:02, 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 = {}
	
	-- Parse each row
	for indent, item in wikitext:gmatch("(**) *([^\n]+)") do  
	    items[#items + 1] = {'*' .. indent, item}
	end

	-- Bold sublist titles and add a blank list item before them
	-- The blank item is used by CSS to make the list item block leel
	for i, item in pairs(items) do  
		if i < #items and #items[i + 1][1] > #item[1] then
			-- Add {{Inline sublist}} after the bold and italics
			local inlineNext = item[2]:match('INLINE%-UL$') ~= ni
			
			if inlineNext then
				item[2] = item[2]:gsub(' *INLINE%-UL$', '')
			end
			
			local post = inlineNext and '&#58;' or ''
			item[2] = '\n' .. item[1] .. "'''''" .. item[2] .. post .. "'''''"
			
			if inlineNext then
				item[2] = item[2] .. '<span class="content-inline-ul"></span>'
			end
		end
	end
	
	local out = ''
	
	for _, item in pairs(items) do
    	out = out .. item[1] .. item[2] .. '\n'
	end
	
	return '<div class="content-list">\n' .. out  .. '</div>' .. frame:extensionTag{
		name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }
	}
end

return p