Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Change the style of the fragment capturing so that we can detect broken fragments
Escape special characters in fragment names
Line 493:
end
if not falsy(options.fragment) then
local escapedFragment = mw.ustring.gsub( options.fragment, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0" )
local fragments = ""
local fragment = ""
local position = 1
while position < mw.ustring.len( text ) do
fragment, position = mw.ustring.match(text, "<%s*[Ss]ection%s+begin%s*=%s*[\"\']?%s*" .. options.fragmentescapedFragment .. "%s*[\"\']?%s*/>(.-)<%s*[Ss]ection%s+end=%s*[\"\']?%s*" .. options.fragmentescapedFragment .. "%s*[\"\']?%s*/>()", position )
if fragment and position then
fragments = fragments .. fragment