Encode non-HTML characters in links and ids

Resolves bug 1214316

Change-Id: I907b572cee082acd434cde415f4b1de85269f1e9