Mô đun:Transclude DYK

local p = {}

-- Transclude randomly selected "Did you know?" entries
function 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 end
	for 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 page
	local page = args[1] or error("Không có tên trang cho")
	local title = mw.title.new(page) or error("Thiếu trang đầu vào " .. page)
	local text = title:getContent() or error("Không có nội dung cho trang " .. page)

	-- Limit to the DYK section if present
	local sectionstart = mw.ustring.find(text, "\n==Bài viết ''Bạn có biết không?''==", 1, true)
	if sectionstart then
		local sectionend = mw.ustring.find(text, "\n==", sectionstart + 1, true) or -1
		text = mw.ustring.sub(text, sectionstart, sectionend)
	end

	-- Parse the entries
	entries = {}
	for entry in mw.ustring.gmatch(text, "\n%*[.…%s]*([^\n]+)") do
		if not mw.ustring.find(entry, "trang thảo luận của bài viết thiếu lời giới thiệu chủ đề", 1, true) then
			table.insert(entries, entry)
		end
	end

	-- Swap some random entries into the first n positions
	local n = math.min(#entries, args.count or 10) -- the number of entries to produce
	math.randomseed(os.time())
	for i = 1, n do
		j = math.random(i, #entries)
		entries[i], entries[j] = "*... " .. entries[j], entries[i]
	end

	-- Return the first n entries
	text = table.concat(entries, "\n", 1, n)
	return frame:preprocess(text)
end

return p
Chúng tôi bán
Bài viết liên quan
[Chongyun] Thuần Dương Chi Thể - Trường sinh bất lão
[Chongyun] Thuần Dương Chi Thể - Trường sinh bất lão
Nếu ai đã từng đọc những tiểu thuyết tiên hiệp, thì hẳn là không còn xa lạ
Nhân vật Mikasa Ackerman trong Shingeki no Kyojin
Nhân vật Mikasa Ackerman trong Shingeki no Kyojin
Mikasa Ackerman (ミカサ・アッカーマン , Mikasa Akkāman) là em gái nuôi của Eren Yeager và là nữ chính của series Shingeki no Kyojin.
"I LOVE YOU 3000" Câu thoại hot nhất AVENGERS: ENDGAME có nguồn gốc từ đâu?
“I love you 3000” dịch nôm na theo nghĩa đen là “Tôi yêu bạn 3000 ”
Jujutsu Kaisen chương 239: Kẻ sống sót ngốc nghếch
Jujutsu Kaisen chương 239: Kẻ sống sót ngốc nghếch
Cô nàng cáu giận Kenjaku vì tất cả những gì xảy ra trong Tử Diệt Hồi Du. Cô tự hỏi rằng liệu có quá tàn nhẫn không khi cho bọn họ sống lại bằng cách biến họ thành chú vật