Sections in tabs etc. should now always work

Replaced an ungodly Perl regexp mess with a (perhaps more ungodly, but
surely more reliable) haskell function