Smarter collapseWhitespace - preserver space around inline tags

I hit a wall in another project so I thought I give this a crack. Note that I changed some one of the tests. I also ran it on two of my live projects and everything renders as expected.