Module:Listing: Difference between revisions

Want an adless experience? Log in or Create an account.
quick demo that outputs a basic list
(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.getSections( pageContent )
function p._parseListing( pageName )
  local pageContent = mw.title.new( pageName ):getContent()
   local currentSection = {
   local currentSection = {
     level = 1,
     level = 1,
     name = "", -- TODO page name (change args to take pagename and get the content in this function)
     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 = [[