Could you be more specific? What sorts of formatting are you wanting to preserve?
I think the problem may be not in how you are storing the data, but in how you are displaying it. Keep in mind that HTML ignores whitespace, including tabs, newlines, etc.; any block of whitespace is treated as a single space character for display purposes. The following 2 paragraphs would display the same:
<p>{tab}This is
my paragraph</p>
<p> This is my paragraph</p>
You may want to replace newlines with <br>, tabs with , etc.
The other alternative is to enclose your text in <pre> </pre> tags which will display the text preformatted, with all newlines, tabs, spaces, etc. intact. The downside is that it will be displayed in a monospace font like Courier.