Link title and caption. Fixes #30

Made the title and caption linked with the URL if we have one. Tidied
the code a little to make it easier to reuse and read.