模块:GetPageCode

来自维阿百科
1.38>牛腩面2022年7月4日 (一) 17:58的版本 (导入1个版本)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

此模块的文档可以在模块:GetPageCode/doc创建

return function(name)
	local code = mw.title.new(name):getContent()
	local redirect = false
	if code == nil then return nil end
	if string.find(code, '^#REDIRECT%s+%[%[.+%]%]%s*$') or string.find(code, '^#重定向%s+%[%[.+%]%]%s*$') then
		redirect = string.gsub(code, '.+%[%[(.+)%]%]%s*$', '%1')
		code = mw.title.new(redirect):getContent()
	end
	return code, redirect
end