17,273
edits
(proof-of-concept parser for listing pages. may or may not decide to use this to generate navboxes) |
(quick demo that outputs a basic list) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p. | function p._parseListing( pageName ) | ||
local pageContent = mw.title.new( pageName ):getContent() | |||
local currentSection = { | local currentSection = { | ||
level = 1, | level = 1, | ||
name = | name = pageName, | ||
content = "", | content = "", | ||
summary = "", | summary = "", | ||
Line 47: | Line 48: | ||
return currentSection | return currentSection | ||
end | end | ||
function p.bullets( frame ) | |||
local listing = p._parseListing( frame.args[1] ) | |||
local bullets = mw.html.create( 'ul' ) | |||
for _, section in ipairs( listing.sections ) do | |||
local sublist = bullets:tag( 'li' ) | |||
:wikitext( section.name ) | |||
:tag( 'ul' ) | |||
for _, subsection in ipairs( section.sections ) do | |||
sublist:tag( 'li' ):wikitext( subsection.name ) | |||
end | |||
end | |||
return tostring( bullets ) | |||
end | |||
p.debugFrame = { | |||
args = { | |||
[1] = 'User:Locke/Sandbox/Listing' | |||
} | |||
} | |||
p.debugContent = [[ | p.debugContent = [[ |