Optimize whitespace trimming on paragraph merge

Avoid some unnecessary work by only trimming insignificant whitespace in the direction of the merge. This is the only place that whitespace can inadvertently become significant whitespace.