Fixed empty reference links.  Closes #1186.

Includes test.