Module:Excerpt: Difference between revisions

Content deleted Content added
Remove unmatched {{ etc. which might break an enclosing template such as {{#tag:gallery}}
Bug fix: avoid truncating after ]]]] because second and third brackets don't form a pair
Line 544:
text = mw.ustring.gsub(text, "%[(%b[])%]", "[\27%1\27]");
until text == t
text = text.gsub(text, "([{}%[%]])%1[^\27].*", ""); -- remove unmatched {{, }}, [[ or ]] and everything thereafter, avoiding ]E]]E] etc.
text = mw.ustring.gsub(text, "\27", ""); -- unhide matched pairs: {E{ → {{, ]E] → ]], etc.