Module documentation
Usage
{{#invoke:Transclude DYK|main}}
- Main documentation: {{Transclude DYK/doc}}
Transcludes randomly selected "Did You Know?" entries from a list.
See also
local p = {}-- Transclude randomly selected "Did you know?" entriesfunction p.main(frame)-- args = { 1,2,... = page names, paragraphs = list e.g. "1,3-5", files = list, more = text}local args = {} -- args[k] = frame.args[k] or frame:getParent().args[k] for all k in either (numeric or not)for k, v in pairs(frame:getParent().args) do args[k] = v endfor k, v in pairs(frame.args) do args[k] = v end -- args from a Lua call have priority over parent args from template-- Read the input pagelocal page = args[1] or error("No page name given")local title = mw.title.new(page) or error("Missing input page " .. page)local text = title:getContent() or error("No content for page " .. page)-- Limit to the DYK section if presentlocal sectionstart = mw.ustring.find(text, "\n==''Did you know?'' articles==", 1, true)if sectionstart thenlocal sectionend = mw.ustring.find(text, "\n==", sectionstart + 1, true) or -1text = mw.ustring.sub(text, sectionstart, sectionend)end-- Parse the entriesentries = {}for entry in mw.ustring.gmatch(text, "\n%*[.…%s]*([^\n]+)") doif not mw.ustring.find(entry, "article's talk page missing blurb", 1, true) thentable.insert(entries, entry)endend-- Swap some random entries into the first n positionslocal n = math.min(#entries, args.count or 10) -- the number of entries to producemath.randomseed(os.time())for i = 1, n doj = math.random(i, #entries)entries[i], entries[j] = "*... " .. entries[j], entries[i]end-- Return the first n entriestext = table.concat(entries, "\n", 1, n)return frame:preprocess(text)endreturn p
🔥 Top keywords: Main PageSpecial:SearchIndian Premier LeagueWikipedia:Featured picturesPornhubUEFA Champions League2024 Indian Premier LeagueFallout (American TV series)Jontay PorterXXXTentacionAmar Singh ChamkilaFallout (series)Cloud seedingReal Madrid CFCleopatraRama NavamiRichard GaddDeaths in 2024Civil War (film)Shōgun (2024 miniseries)2024 Indian general electionJennifer PanO. J. SimpsonElla PurnellBaby ReindeerCaitlin ClarkLaverne CoxXXX (film series)Facebook2023–24 UEFA Champions LeagueYouTubeCandidates Tournament 2024InstagramList of European Cup and UEFA Champions League finalsJude BellinghamMichael Porter Jr.Andriy LuninCarlo AncelottiBade Miyan Chote Miyan (2024 film)