Module:Excerpt: Difference between revisions

Content deleted Content added
Handle section names containing URL-escaped characters and characters special to Lua patterns
Line 477:
-- Parse a ==Section== from a page
local function getsection(text, section, mainonly)
local level, contentescapedSection = mw.ustring.matchgsub(text mw.uri. "\n"decode(section), "\n(==+[%^%$%(%)%s%%.%[%]%*%+%-%?])", .."%%%1") section-- ..%26 → & etc, then ^ → "%s*==^ etc.-\n(.*)")
local level, content = mw.ustring.match(text .. "\n", "\n(==+)%s*" .. escapedSection .. "%s*==.-\n(.*)")
if not content then return nil end -- no such section
local nextsection