Module:Excerpt slideshow/sandbox: Difference between revisions

Content deleted Content added
m cleanup
test
Line 116:
-- else replace pipes and remove internal linebreaks
return replacePipesWithMagicword(mw.ustring.gsub(t, '\n*', ''))
end
 
local cleanUpExcerpt = function(excerpt)
-- strip galleries
excerpt = mw.ustring.gsub(excerpt, "<%s*[Gg]allery.->.-<%s*/%s*[Gg]allery%s*>", "")
-- strip tables and block templates; strip newlines and replace pipes within inline templates
excerpt = mw.ustring.gsub(excerpt..'\n', '\n?%b{}\n?', processBraces)
-- replace pipes within links
excerpt = mw.ustring.gsub(excerpt, '%b[]', replacePipesWithMagicword)
-- replace other pipes with html entity
excerpt = mw.ustring.gsub(excerpt, '|', '&#124;')
-- replace wikitext bulleted lists with html bulleted lists
excerpt = gsubWikitextLists(excerpt, '*', 'ul', 'li')
-- replace wikitext numbered lists with html numbered lists
excerpt = gsubWikitextLists(excerpt, '#', 'ol', 'li')
excerpt = mw.text.trim(excerpt)
return excerpt
end
 
Line 135 ⟶ 152:
end
if excerpt and excerpt ~= '' and #excerpt > 10 then -- check again in case we had a few characters plus Read more...
excerpt = cleanUpExcerpt(excerpt)
-- strip galleries
excerpt = mw.ustring.gsub(excerpt, "<%s*[Gg]allery.->.-<%s*/%s*[Gg]allery%s*>", "")
-- strip tables and block templates; strip newlines and replace pipes within inline templates
excerpt = mw.ustring.gsub(excerpt..'\n', '\n?%b{}\n?', processBraces)
-- replace pipes within links
excerpt = mw.ustring.gsub(excerpt, '%b[]', replacePipesWithMagicword)
-- replace other pipes with html entity
excerpt = mw.ustring.gsub(excerpt, '|', '&#124;')
-- replace wikitext bulleted lists with html bulleted lists
excerpt = gsubWikitextLists(excerpt, '*', 'ul', 'li')
-- replace wikitext numbered lists with html numbered lists
excerpt = gsubWikitextLists(excerpt, '#', 'ol', 'li')
excerpt = mw.text.trim(excerpt)
if options.more then
excerpt = excerpt .. " ('''[[" .. title .. "|" .. options.more .. "]]''')"
Line 271 ⟶ 276:
p._excerpt = function(_args, method)
local args = cleanupArgs(_args)
args.more = excerptModule.getMoreLinkText(_args.more)
-- check for blank value in more parameter
if _args.more and not args.more then
args.more = "Read more..." -- default text for blank more=
end
local options = makeOptions(args)
local limit = args.limit and tonumber(args.limit) or DEFAULT_LIMIT
Line 286 ⟶ 288:
return slideshowModule._main(galleryArgs, false, 'excerptSlideshow-container') .. checksourcepages()
end
 
p._cleanUpExcerpt = cleanUpExcerpt
 
-- begin BHG addition for tracking source pages