Content deleted Content added
BrandonXLF (talk | contribs) No edit summary |
BrandonXLF (talk | contribs) No edit summary |
||
Line 1:
-- Sandbox, do not delete
local p = {}
local function closePending(toClose, depth)
local out = ''▼
return out
end
function p.main(frame)
local wikitext = frame:preprocess(frame.args[1])
local items = {}
local out = ''
for indent, item in wikitext:gmatch("(**) *([^\n]+)") do
items[#items + 1] = {
end
-- List of { depth, closing tag [, rest block-level (for <ul>s) ] }
local toClose = {}
▲ local out = ''
for i, item in pairs(items) do
▲ -- Close <li> and <ul> enclosing deeper items
▲ while #toClose > 0 and #toClose[#toClose][1] >= #item[1] do
▲ out = out .. toClose[#toClose][2]
▲ table.remove(toClose, #toClose)
▲ end
-- Create a new
out = out .. '<ul>'
toClose[#toClose + 1] = { item[1]
end
Line 33 ⟶ 39:
if keepInline then
out = out .. '<li>' .. item[2]:gsub(' *KEEP%-INLINE$', '') .. '<span class="content-list-inline"> </span>'
-- Remove ":" if first item is block-level
▲ elseif toClose[#toClose][3] or i < #items and #items[i + 1][1] > #item[1] then
out = out:gsub(": '''''<ul>$", "'''''<ul><ul>")
-- Treat remaining items in this last as block-level
toClose[#toClose][3] = true
out = out .. '<li class="content-sublist">' .. "'''''" .. item[2] .. ": '''''"
elseif toClose[#toClose][3] then
out = out .. '<li class="content-sublist">' .. "'''''" .. item[2] .. "
else
out = out .. '<li>' .. item[2]
▲ out = out .. item[2]
end
Line 47 ⟶ 55:
end
out = out .. closePending(toClose, 0)
return '<div class="content-list"
name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }
}
|