Changes

681 bytes added ,  22:53, 5 August 2013
edited for clarity
local str = require( 'Module:StringHelper' )
local p = {}

-- generate a bulleted list of section headings extracted from a page.
-- the page is passed as the first argument.
-- example: {{#invoke:Sandbox/RobLa/Foo|captions|Lua scripting/status}}
function p.captions( frame )
local title = frame.args[1]
local page = mw.title.new( title )
local content = page:getContent()
local captions = ''

for line in str.lines( content ) do
if str.startswith(line, '== ') and str.endswith(line, ' ==') then
item = '* ' .. str.strip( line, '= ') .. '\n'
captions = captions .. item
end
end

return captions
end

return p
Anonymous user