Module:Excerpt: Difference between revisions

Content deleted Content added
Add showall= to show all excerpts from selectable articles
Add option to keep references, see talk page
Line 511:
end
 
local function cleanupText(text, leadOnly, keepRefs)
text = mw.ustring.gsub(text, "<!%-%-.-%-%->","") -- remove HTML comments
if leadOnly then
Line 523:
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 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 cited elsewhere
text = mw.ustring.gsub(text, "<%s*[Rr][Ee][Ff][^.->].-<%s*/%s*[Rr][Ee][Ff]%s*>", "") -- remove refs cited elsewhere
end
text = mw.ustring.gsub(text, "<%s*[Ss][Cc][Oo][Rr][Ee].->.-<%s*/%s*[Ss][Cc][Oo][Rr][Ee]%s*>", "") -- remove musical scores
text = mw.ustring.gsub(text, "<%s*[Ii][Mm][Aa][Gg][Ee][Mm][Aa][Pp].->.-<%s*/%s*[Ii][Mm][Aa][Gg][Ee][Mm][Aa][Pp]%s*>", convertImagemap) -- convert imagemaps into standard images
Line 623 ⟶ 625:
if not text then return err("Cannot read a valid page: first name is " .. firstpage) end
 
local keepRefs = options.keepRefs
text = cleanupText(text, true, keepRefs)
 
local pageopts = {} -- pageopts (even if value is "") have priority over global options
Line 768 ⟶ 771:
function p.checkimage(image) return checkimage(image) end
function p.parseimage(text, start) return parseimage(text, start) end
function p.cleanupText(text, leadOnly, keepRefs) return cleanupText(text, leadOnly, keepRefs) end
function p.main(pagenames, options) return main(pagenames, options) end
function p.numberflags(str) return numberflags(str) end