Pete Freitag Pete Freitag

ParagraphFormat is not XHTML Safe

coldfusion

I just noticed that the ParagraphFormat tag is not XHTML safe. It inserts unclosed <P> tags for line breaks. I posted a comment on the live docs about this, so hopefully they will add an optional argument to have it generate XHTML output. Here's a function you can use in the meantime:

<cffunction name="XHTMLParagraphFormat" returntype="string" output="false">
	<cfargument name="str" required="true" type="string">
	<cfreturn REReplace(arguments.str, "\r+\n\r+\n", "<br /><br />", "ALL")>
</cffunction>

Like this? Follow me ↯

ParagraphFormat is not XHTML Safe was first published on May 06, 2005.


FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.

Comments

There's also an XHTMLParagraphFormat UDF on CFLib.org.
by Steve Ray on 05/06/2005 at 5:22:15 PM UTC
There is a cflib function for this too. :)
by Raymond Camden on 05/06/2005 at 6:35:38 PM UTC
The function on cflib is not exactly ideal. It will convert blank lines into empty &lt;p&gt;&lt;/p&gt; tags which is not exactly correct. I changed the code from a replace to a reReplaceNoCase with the following regexp to do the right thing (from a semantic XHTML point of view): reReplaceNoCase(string, "(#Chr(13)##Chr(10)#)+", ...)
by Brian G on 02/03/2006 at 5:41:14 PM UTC