Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Add truthy check for nobold
Rename truthy() for falsy(), as the function actually checked for falsy values
Line 67:
end
 
-- Helper function to test for truthyfalsy values
local function truthyfalsy( value )
if not value or value == "" or value == "0" or value == "false" or value == "no" then
return falsetrue
end
return truefalse
end
 
Line 480:
t = t .. token -- keep wanted block templates
 
elseif truthynot falsy(options.keepTables) and mw.ustring.sub(token, 1, 2) == '{|' then
t = t .. token -- keep tables
 
Line 541:
local function cleanupText(text, keepSubsections, keepRefs)
text = mw.ustring.gsub(text, "<!%-%-.-%-%->","") -- remove HTML comments
if not truthyfalsy(keepSubsections) then
text = mw.ustring.gsub(text, "\n==.*","") -- remove first ==Heading== and everything after it
text = mw.ustring.gsub(text, "^==.*","") -- ...even if the lead is empty
Line 551:
text = mw.ustring.gsub(text, "</[Oo][Nn][Ll][Yy][Ii][Nn][Cc][Ll][Uu][Dd][Ee]>.*", "") -- remove text after last onlyinclude section
end
if not truthyfalsy(keepRefs) then
text = mw.ustring.gsub(text, "<%s*[Rr][Ee][Ff][^>]-/%s*>", "") -- remove refs cited elsewhere
text = mw.ustring.gsub(text, "<%s*[Rr][Ee][Ff].->.-<%s*/%s*[Rr][Ee][Ff]%s*>", "") -- remove refs
Line 692:
 
-- remove '''bold text''' if requested
if truthynot falsy(pageopts.nobold) then text = mw.ustring.gsub(text, "'''", "") end
 
text = filetext .. text