Fix the whitespace stripper with new sandbox APIs. Fixes #142

Ok, I did it. The stripper code got even longer, but it's working ;-)

I confirmed after autosave, selection stays alive.