Category and interwiki links typically strip whitespace preceding them.
There's an odd special case, though: they *also* strip trailing newlines *if newlines are the only thing between the category/interwiki and the next link*.
This is arguably counterintuitive behavior, for example:
[[Category:Foo]] [[Foo]][[es:Alimento]] [[Foo]]
renders as [[Foo]][[Foo]] due to this weird special case.
I think this behavior can be removed, but since the last time I touched this code my fix had to be reverted after unexpected consequences (T174639), I'm going to play it safe and make this a separate issue/patch set.