Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Finish removing the need to internationalize and localize redirects
Replace leadOnly for keepSubsections
Line 531:
end
 
local function cleanupText(text, leadOnlykeepSubsections, keepRefs)
text = mw.ustring.gsub(text, "<!%-%-.-%-%->","") -- remove HTML comments
if leadOnlynot keepSubsections then
text = mw.ustring.gsub(text, "\n==.*","") -- remove first ==Heading== and everything after it
text = mw.ustring.gsub(text, "^==.*","") -- ...even if it's the startlead ofis the article (blank lead)empty
end
text = mw.ustring.gsub(text, "<[Nn][Oo][Ii][Nn][Cc][Ll][Uu][Dd][Ee]>.-</[Nn][Oo][Ii][Nn][Cc][Ll][Uu][Dd][Ee]>", "") -- remove noinclude bits
Line 647:
if not text then return err("Cannot read a valid page: first name is " .. firstpage) end
 
local keepRefs = options.keepRefs
local keepSubsections = options.keepSubsections
if options.keepRefs == '1' then keepRefs = true else keepRefs = false end
text = cleanupText(text, leadOnlykeepSubsections, keepRefs)
local leadOnly = not section or section == ""
text = cleanupText(text, leadOnly, keepRefs)
 
local pageopts = {} -- pageopts (even if value is "") have priority over global options
Line 814 ⟶ 813:
function p.checkimage(image) return checkimage(image) end
function p.parseimage(text, start) return parseimage(text, start) end
function p.cleanupText(text, leadOnlykeepSubsections, keepRefs) return cleanupText(text, leadOnlykeepSubsections, keepRefs) end
function p.main(pagenames, options) return main(pagenames, options) end
function p.numberflags(str) return numberflags(str) end