Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Add option to excerpt a fragment wrapped with <section> tags. Also change cleanupText so that it takes a single table of parameters
Improve fragment transclusion so that multiple fragments with the same name are transcluded
Line 493:
end
if not falsy(options.fragment) then
local fragmenttext = mw.ustring.matchgsub(text, "<%s*[Ss]ection%s+begin%s*end=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>(.-)<%s*[Ss]ection%s+endbegin%s*=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>", "") -- remove text between <sections>
text = mw.ustring.gsub(text, "^.-<%s*[Ss]ection%s+begin=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>", "") -- remove text before first <section>
if fragment then text = fragment else text = "" end
text = mw.ustring.gsub(text, "<%s*[Ss]ection%s+end=%s*[\"\']?%s*" .. options.fragment .. "%s*[\"\']?%s*/>.*", "") -- remove text after last <section>
end
if falsy(options.keepSubsections) then