Jump to content

Module:Excerpt/portals and Module:Excerpt/portals/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Fix over-culling templates when doing stripTemplate as part of ref cleanup if there's a piped wikilink in an unexpected position
 
From live (Fix over-culling templates when doing stripTemplate as part of ref cleanup if there's a piped wikilink in an unexpected position)
 
Line 42: Line 42:
-- Regular expressions to match all inline templates that are undesirable in excerpts
-- Regular expressions to match all inline templates that are undesirable in excerpts
local unwantedInlineTemplates = {
local unwantedInlineTemplates = {
"[Ee]fn", "[Ee]fn%-[lu][arg]", "[Ee]fn [%a ]-", "[Ee]l[mn]", "[Rr]p?", "[Ss]fn[bmp]", "[Ss]f[bn]", "[Nn]ote[Tt]ag", "#[Tt]ag:%s*[Rr]ef", "[Rr]efn?", "[Ff]amily[ _]name[ _]footnote",
"[Ee]fn", "[Ee]fn%-[lu][arg]", "[Ee]fn [%a ]-", "[Ee]l[mn]", "[Rr]p?", "[Ss]fn[bmp]", "[Ss]f[bn]", "[Nn]ote[Tt]ag", "#[Tt]ag:%s*[Rr]ef", "[Rr]efn?",
"[CcDd]n", "[Cc]itation[%- _]needed", "[Dd]isambiguation needed", "[Ff]eatured article", "[Gg]ood article",
"[CcDd]n", "[Cc]itation[%- _]needed", "[Dd]isambiguation needed", "[Ff]eatured article", "[Gg]ood article",
"[Dd]ISPLAYTITLE", "[Ss]hort[ _]+description", "[Cc]itation", "[Cc]ite[%- _]+[%w_%s]-", "[Cc]oor[%w_%s]-",
"[Dd]ISPLAYTITLE", "[Ss]hort[ _]+description", "[Cc]itation", "[Cc]ite[%- _]+[%w_%s]-", "[Cc]oor[%w_%s]-",
Line 111: Line 111:
}
}


local Transcluder = require("Module:Transcluder/sandbox")
-- Regular expressions to match non-free file templates
local nonFreeFileTemplates = {
"[Nn]on%-free",
}

local Transcluder = require("Module:Transcluder")
local escapeString = require("Module:String")._escapePattern
local escapeString = require("Module:String")._escapePattern
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
Line 299: Line 294:


-- Filter non-free images
-- Filter non-free images
if not fileDescription or fileDescription == "" or matchAny(fileDescription, "", nonFreeFileTemplates, "") then
if not fileDescription or fileDescription == "" or mw.ustring.match(fileDescription, "[Nn]on%-free") then return false end
return false
end


return true
return true
Line 969: Line 962:
end
end
if not text or text == "" then return wikiError("No valid pages found") end
if not text or text == "" then return wikiError("No valid pages found") end

-- Store all candidates before processing
local allCandidates = {page} -- Include current page
for _, candidate in pairs(candidates) do
table.insert(allCandidates, candidate)
end


if args.showall then
if args.showall then
local separator = args.showall
local separator = args.showall
if separator == "" then separator = "{{clear}}{{hr}}" end
if separator == "" then separator = "{{clear}}{{hr}}" end
-- Add list at the top for showall if list parameter is not present
if not args.list then
local listText = "{{collapse top|title={{resize|85%|List of articles in rotation}}|bg=fff}}{{hlist"
for _, candidate in pairs(allCandidates) do
if mw.ustring.match(candidate, "%S") then
listText = listText .. "|[[" .. mw.text.trim(candidate) .. "]]"
end
end
listText = listText .. "}}\n{{collapse bottom}}\n"
text = listText .. text
end
for _, candidate in pairs(candidates) do
for _, candidate in pairs(candidates) do
local t = get(candidate, options)
local t = get(candidate, options)
Line 997: Line 973:
end
end
end
end



-- Add a collapsed list of pages which might appear
-- Add a collapsed list of pages which might appear
if args.list then
if args.list and not args.showall then
local list = args.list
local list = args.list
if list == "" then list = "Other articles" end
if list == "" then list = "Other articles" end