|Delete empty sections|
|What it does:||Removes empty sections from pages|
Delete empty sections is a bit of replace.py regex that will help you get rid of empty sections on pages. All too frequently people put empty sections into pages, thinking that eventually they'll get filled in. So they might type something like:
== External links == ''to be added''
But there are many, many pages that will never have external links. This regex scans for a section like this and then deletes it.
python replace.py -regex "\=\=( *?)External .*\n''.*''" ""
This regex will match a wide variety of permutations including:
==External links === to be added == External links== ''to be added'' ==External link == ''coming soon'' ==External links== ''N/A''
This script does expect for the "to be added" — or equivalent — line to be on the line directly underneath the section head. If there's an additional carriage return, this regex won't match.
This regex also expects a rational use of two equals signs around the section title. It could be easily fixed to check for any number of equal signs with this expression: (\=*?)
Also, because it was the practice that had emerged at w:c:tardis, this script also assumes that the line under the section head will be italicised. The regex could easily be changed to not expect that by simply removing the apostrophes.