Ask a Jedi: Help in preserving user input

A reader asks:

I want to create a discussion board where I can retain the carriage returns that my users have entered - how can I pull their entries from the Database and retain the carriage returns without using the <pre> tags?

Out of the box, ColdFusion provides us with a paragraphFormat() function. This will correctly format blocks of text in paragraphs, inserting a P tag at blank lines. However, it won't correctly notice simple line breaks, like in an address. You can get around this by using a user-defined function like paragraphFormat2, written by Ben Forta. This UDF simply looks out for line breaks and inserts a BR tag. I use this on my Galleon ColdFusion forums.

Comments

Joe Lencioni's Gravatar I was recently struggling with this same issue and found the solutions floating around the Inetenet to be less than perfect. So, I came up with a new <a href="http://www.gustavus.edu/oncampus/gts/webservices/a... function</a> that you might find helpful.

Unfortunately, it's not perfect yet because I haven't had the time to properly test it, but it seems to be performing quite well so far.
# Posted By Joe Lencioni | 1/30/06 11:35 AM
Chris Bunting's Gravatar Hello,
One way to fix this is to install or include and online editor like khtml or fckeditor.
# Posted By Chris Bunting | 1/30/06 7:29 PM
Joe Lencioni's Gravatar Yes, I have used FCKEditor in some projects and it is very slick. Another good one is TinyMCE.
# Posted By Joe Lencioni | 1/30/06 7:39 PM