Make markdown TOC and anchors more plaintext-friendly.

Reviewed at https://reviews.apache.org/r/18528/