Escape anchor strings

Anchors generated by IPython have trailing newlines for some reason, which breaks the TOC links if they aren't escaped.