Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Improve fragment transclusion so that multiple fragments with the same name are transcluded
Change the style of the fragment capturing so that we can detect broken fragments
Line 493:
end
if not falsy(options.fragment) then
local fragments = ""
text = mw.ustring.gsub(text, "<%s*[Ss]ection%s+end=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>.-<%s*[Ss]ection%s+begin%s*=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>", "") -- remove text between <sections>
local fragment = ""
text = mw.ustring.gsub(text, "^.-<%s*[Ss]ection%s+begin=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>", "") -- remove text before first <section>
local position = 1
text = mw.ustring.gsub(text, "<%s*[Ss]ection%s+end=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>.*", "") -- remove text after last <section>
while position < mw.ustring.len( text ) do
text fragment, position = mw.ustring.gsubmatch(text, "<%s*[Ss]ection%s+endbegin%s*=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>(.-)<%s*[Ss]ection%s+begin%s*end=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>()", ""position ) -- remove text between <sections>
if fragment and position then
fragments = fragments .. fragment
else
position = mw.ustring.len( text )
end
end
text = fragments
end
if falsy(options.keepSubsections) then