How to preserve rich text formatting?