Module:Excerpt slideshow/sandbox: Difference between revisions

Content deleted Content added
include random slideshow templatestyles
shuffle around
 
(9 intermediate revisions by 2 users not shown)
Line 1:
local p = {}
local excerptModule = require('Module:Excerpt/portals/sandbox')
local slideshowModule = require('Module:Random slideshow/sandbox')
local randomModule = require('Module:Random')
Line 88:
end
)
end
 
local replacePipesWithMagicword = function(t)
return mw.ustring.gsub(t, '|', '{{!}}')
end
 
Line 114 ⟶ 110:
return frame:preprocess(t)
end
-- else replace pipes and remove internal linebreaks
return replacePipesWithMagicword(mw.ustring.gsub(t, '\n*', ''))
end
 
Line 121 ⟶ 117:
-- 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')
Line 156 ⟶ 148:
excerpt = excerpt .. " ('''[[" .. title .. "|" .. options.more .. "]]''')"
end
local text = '<div style{{=}}"text-align:left;">' .. mw.ustring.gsub(excerpt, '%c', '<br>') .. '</div>'
table.insert(galleryArgs, 'File:Blank.png')
table.insert(galleryArgs, text)
Line 178 ⟶ 170:
options.paraflags = excerptModule.numberFlags(args.paragraphs or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
options.fileflags = excerptModule.numberFlags(args.files or "") -- parse file numbers
options.ignoreOnlyincludes = options.ignoreOnlyincludes == nil and true or options.ignoreOnlyincludes -- default to true
if args.nostubs and isDeclined(args.nostubs) then
options.nostubs = false
Line 211 ⟶ 204:
-- begin BHG addition for tracking source pages
local thisPage = mw.title.getCurrentTitle().nsText .. ":" .. mw.title.getCurrentTitle().text
thisPage = thisPage:gsub('_', ' ') -- fix the nsText part, until [[phab:T369784]] is resolved
local thisBareParam = mw.ustring.gsub(args[ii], "^([^#]+).*$", "%1", 1) -- strip any section anchor from the parameter's page name
thisBareParam = thisBareParam:gsub('_', ' ') -- support underscores in parameter's page name
if (thisPage == thisBareParam) then
usesEmbeddedList = true;