I store the htmlText
property of a RichTextEditor
in the database.
I retrieve it in another instance and I want to show the user the first line of it as plain text
So I let Flex handle the conversion by using a function like this
var editor:TextField = new TextField();
editor.htmlText = htmlTextFromDb;
var converted:String = editor.text;
However, the issue is that this conversion does not handle lines properly. I get everything in one line!
Lets say what I get from the database is this
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line one</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line two</FONT></P></TEXTFORMAT>
As soon as I say editor.htmlText = htmlTextFromDb
, editor.htmlText becomes
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line oneThis is line two</FONT></P></TEXTFORMAT>
It acts as if new lines are not present.
How do I solve this?
tags to handle new lines.
– Ranhiru Jude Cooray Jun 28 '11 at 10:16