17,273
edits
(quick demo that outputs a basic list) |
(add ^...$ to heading regex) |
||
Line 13: | Line 13: | ||
-- can't think of a regex to split sections so go line by line | -- can't think of a regex to split sections so go line by line | ||
for line in mw.text.gsplit( pageContent, '\n' ) do | for line in mw.text.gsplit( pageContent, '\n' ) do | ||
local headingLevel, headingText = string.match( line, '%s*(=+)%s*(.-)%s*=+' ) | local headingLevel, headingText = string.match( line, '^%s*(=+)%s*(.-)%s*=+$' ) | ||
if headingLevel then -- line is a heading | if headingLevel then -- line is a heading | ||
local newSection = { | local newSection = { |