Module:PullSection
From Pixelmon Wiki
Documentation for this module may be created at Module:PullSection/doc
local p = {} function p.main(frame) local pageName = frame.args.page local sectionName = frame.args.section if not pageName or not sectionName then return "Error: You must specify both a page and a section." end -- Fetch the page content local page = mw.title.new(pageName) if not page then return "Error: Page not found." end local pageContent = page:getContent() if not pageContent then return "Error: Unable to retrieve page content." end -- Extract the section local sectionContent = mw.text.split(pageContent, '== ' .. sectionName .. ' ==')[2] if not sectionContent then return "Error: Section not found." end -- Return the content of the section local nextSection = mw.text.split(sectionContent, '==')[2] if nextSection then sectionContent = mw.text.trim(sectionContent:sub(1, nextSection:find('==') - 1)) end -- Remove HTML tags from section content local cleanedContent = mw.text.strip(mw.html.removeTags(sectionContent)) -- Return the cleaned content return cleanedContent end return p