More languages
More actions
m (Testing capture of headers) |
m (Added comments) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.test( frame ) | function p.test( frame ) | ||
-- Get contents of page | |||
local pageContent = tostring(mw.title.getCurrentTitle():getContent()) | local pageContent = tostring(mw.title.getCurrentTitle():getContent()) | ||
-- Split contents of page in lines | |||
local pageLines = mw.text.split(pageContent,'\n',true) | local pageLines = mw.text.split(pageContent,'\n',true) | ||
local render = '' | local render = '' | ||
for i=1,#pageLines do | for i=1,#pageLines do | ||
-- Get every line starting with '==', that is, a header | |||
if mw.text.split(pageLines[i], '%s')[1] == '==' then | if mw.text.split(pageLines[i], '%s')[1] == '==' then | ||
render = render | render = render .. pageLines[i] | ||
end | end | ||
end | end |
Latest revision as of 19:16, 14 April 2024
local p = {}
function p.test( frame )
-- Get contents of page
local pageContent = tostring(mw.title.getCurrentTitle():getContent())
-- Split contents of page in lines
local pageLines = mw.text.split(pageContent,'\n',true)
local render = ''
for i=1,#pageLines do
-- Get every line starting with '==', that is, a header
if mw.text.split(pageLines[i], '%s')[1] == '==' then
render = render .. pageLines[i]
end
end
return render
end
return p