|Delink section headers|
|What it does:||Strips links in section headers|
Delink section headers is a bit of regex that will help you strip links from section headers. If your users have gone crazy with links, you may find that you suddenly have to worry about linked text in section headers. Because links are frequently a different color from header text, your whole site design could be compromised by this pernicious practice. This bit of regex will strip the links away but leave behind what's inside
python replace.py -summary:"Getting rid of links in headlines" -regex -start:! "\=\=(.*?)\[\[\:[Cc]ategory\:(.*?)\|(.*?)\]\](.*?)\=\=" "==\1\2\4=="
This main example actually demonstrates one of the more complex cases:
=== [[:category:movies|Movie]] roles ===
This isn't really desirable because in most style sheets Movie would render in a different color to roles. What the script does is to remove the word Movie from the brackets, resulting in:
=== Movie roles ===
Known limitations Edit
In the form above, only links to category pages would be stripped. But this regex could be easily modified in a number of different ways. You could excise the :[Cc]ategory: bit if you wanted to concentrate on links to regular pages. You could make it a little bit fancier by replacing :[Cc]ategory: with another instance of .*?, which would check for anything prior to a pipe, and thereby catch not just category calls, but also calls to any other namespace (except namespace:0).