I may be naive, but how about this?
a) Escape everything 100%.
b) Look for <a> tags, grab their href attribute, escape it, and insert them as <a href='$1'>$2</a>.
c) Do the same for <b>, <p>, etc.
How would that be vulnerable to XSS? A small whitelist of HTML would be replaced safely, and any script tags and so on would be escaped and displayed as is.