Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Shmooblesworld Wiki
Search
Search
Create account
Log in
Personal tools
Dark mode
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Suppress categories
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This is a simple module to strip categories from wikitext. It does -- not support nested links or magic words like __TOC__, etc. Even so, -- it should still handle most categories. local p = {} -- Detects if a category link is valid or not. If it is valid, -- the function returns the blank string. If not, the input -- is returned with no changes. local function processCategory( all, submatch ) local beforePipe = mw.ustring.match( submatch, '^(.-)[%s_]*|[%s_]*.-$' ) beforePipe = beforePipe or submatch if mw.ustring.match( beforePipe, '[%[%]<>{}%c\n]' ) then return all else return '' end end -- Preprocess the content if we aren't being called from #invoke, -- and pass it to gsub to remove valid category links. local function suppress( content, isPreprocessed ) if not isPreprocessed then content = mw.getCurrentFrame():preprocess( content ) end content = mw.ustring.gsub( content, '(%[%[[%s_]*[cC][aA][tT][eE][gG][oO][rR][yY][%s_]*:[%s_]*(.-)[%s_]*%]%])', processCategory ) return content end -- Get the content to suppress categories from, and find -- whether the content has already been preprocessed. (If the -- module is called from #invoke, it has been preprocessed already.) function p.main( frame ) local content, isPreprocessed if frame == mw.getCurrentFrame() then content = frame:getParent().args[1] if frame.args[1] then content = frame.args[1] end isPreprocessed = true else content = frame isPreprocessed = false end return suppress( content, isPreprocessed ) end return p
Summary:
Please note that all contributions to Shmooblesworld Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width