Enhance ampersand escaping.

& followed by # should not be escaped as it's html encoded character.