Module:NoCitations
Mandhari
Hati za moduli hii zinaweza kuanzishwa kwenye Moduli:NoCitations/hati
local p = {}
function p.fetchContent(frame)
local title = frame.args[1] or mw.title.getCurrentTitle().text -- Use current page if no argument
local page = mw.title.new(title)
if not page or not page.exists then
return "Page not found!"
end
local content = page:getContent()
content = p.removeCitations(content)
content = p.removeReferencesSection(content)
return content
end
function p.removeCitations(text)
-- Remove {{Cite web}}, {{Cite book}}, {{Cite encyclopedia}}, etc.
text = mw.ustring.gsub(text, "{{Cite [^}]-}}", "")
return text
end
function p.removeReferencesSection(text)
-- Remove everything from "== References ==" to the end
text = mw.ustring.gsub(text, "==%s*[Rr]eferences%s*==.*", "")
return text
end
return p