From Wikipedia, the free encyclopedia


-- Sandbox, do not delete

local p = {}



-- Close <li> and <ul> enclosing deeper depths

local function closePending(toClose, depth)

	local out = ''

	

	while #toClose > 0 and toClose#toClose][1 >= depth do

		out = out .. toClose#toClose][2

		table.remove(toClose, #toClose)

	end

	

	return out

end



function p.main(frame)

	local wikitext = frame:preprocess(frame.args1])

	local items = {}

	local out = ''

	

	for indent, item in wikitext:gmatch("(**) *([^\n]+)") do  

	    items#items + 1 = {#indent + 1, item}

	end

	

	-- List of { depth, closing tag [, rest block-level (for <ul>s) ] }

	local toClose = {}



	for i, item in pairs(items) do  

		out = out .. closePending(toClose, item1])

		

		-- Create a new list if needed

		if #toClose == 0 or toClose#toClose][2 ~= '</ul>' then

			out = out .. '<ul>'

			toClose#toClose + 1 = { item1 - 1, '</ul>', false }

		end

		

		-- Added by {{Keep inline}}

		local keepInline = item2]:match('KEEP%-INLINE$') ~= nil

		

		if keepInline then

			out = out .. '<li>' .. item2]:gsub(' *KEEP%-INLINE$', '') .. '<span class="content-list-inline"> </span>'

		elseif i < #items and itemsi + 1][1 > item1 then

			-- Remove ":" if first item is block-level

			out = out:gsub("&#58; '''''<ul>$", "'''''<ul><ul>")

			-- Treat remaining items in this last as block-level

			toClose#toClose][3 = true

			out = out .. '<li class="content-sublist">' .. "'''''" .. item2 .. "&#58; '''''"

		elseif toClose#toClose][3 then

			out = out .. '<li class="content-sublist">' .. "'''''" .. item2 .. "'''''"

		else

			out = out .. '<li>' .. item2

		end

		

		toClose#toClose + 1 = { item1], '</li>' }

	end

	

	out = out .. closePending(toClose, 0)

	

	return '<div class="content-list">\n' .. out  .. '</div>' .. frame:extensionTag{

		name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }

	}

end



return p
From Wikipedia, the free encyclopedia


-- Sandbox, do not delete

local p = {}



-- Close <li> and <ul> enclosing deeper depths

local function closePending(toClose, depth)

	local out = ''

	

	while #toClose > 0 and toClose#toClose][1 >= depth do

		out = out .. toClose#toClose][2

		table.remove(toClose, #toClose)

	end

	

	return out

end



function p.main(frame)

	local wikitext = frame:preprocess(frame.args1])

	local items = {}

	local out = ''

	

	for indent, item in wikitext:gmatch("(**) *([^\n]+)") do  

	    items#items + 1 = {#indent + 1, item}

	end

	

	-- List of { depth, closing tag [, rest block-level (for <ul>s) ] }

	local toClose = {}



	for i, item in pairs(items) do  

		out = out .. closePending(toClose, item1])

		

		-- Create a new list if needed

		if #toClose == 0 or toClose#toClose][2 ~= '</ul>' then

			out = out .. '<ul>'

			toClose#toClose + 1 = { item1 - 1, '</ul>', false }

		end

		

		-- Added by {{Keep inline}}

		local keepInline = item2]:match('KEEP%-INLINE$') ~= nil

		

		if keepInline then

			out = out .. '<li>' .. item2]:gsub(' *KEEP%-INLINE$', '') .. '<span class="content-list-inline"> </span>'

		elseif i < #items and itemsi + 1][1 > item1 then

			-- Remove ":" if first item is block-level

			out = out:gsub("&#58; '''''<ul>$", "'''''<ul><ul>")

			-- Treat remaining items in this last as block-level

			toClose#toClose][3 = true

			out = out .. '<li class="content-sublist">' .. "'''''" .. item2 .. "&#58; '''''"

		elseif toClose#toClose][3 then

			out = out .. '<li class="content-sublist">' .. "'''''" .. item2 .. "'''''"

		else

			out = out .. '<li>' .. item2

		end

		

		toClose#toClose + 1 = { item1], '</li>' }

	end

	

	out = out .. closePending(toClose, 0)

	

	return '<div class="content-list">\n' .. out  .. '</div>' .. frame:extensionTag{

		name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }

	}

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook