Module:Pages

維基文庫,自由的圖書館
跳到导航 跳到搜索
模块文档
local p = {};

local function get_page(title)
	local frame = mw.getCurrentFrame()
	local protect=string.gsub(frame:expandTemplate{ title = title }, "\n\n+", "double_breaks")
	local remove=string.gsub(protect, "\n", "")
	local restore=string.gsub(remove, "double_breaks", "\n\n")
	return restore
end

out=""
function p.pages(code)
	local index=code.args[1]
	local from=tonumber(code.args[2])
	local to=tonumber(code.args[3])

	local page=from
	while ( page<=to ) do
 		out=out..get_page(":page:"..index.."/"..page)
 		page=page+1
	end
	return out
end
return p;