Only remove spaces and tabs before <ref> tags, not newlines

Prevents awkward situations. See diff at
https://en.wikipedia.org/w/index.php?title=Château_Haldimand&diff=prev&o
ldid=603494895