Replaces special characters in a string with their HTML-escaped equivalents and inserts <pre> and </pre> tags at the beginning and end of the string.
The only difference between this function and HTMLEditFormat is that HTMLEditFormat doesn't surround the text in HTML pre tags.

htmlCodeFormat(string [, version]) → returns string

Argument Reference

string string

A String or variable that contains one.

version numeric
Default: 2.0

HTML version to use. Currently ignored.
-1: The latest implementation of HTML
2.0: HTML 2.0 (Default)
3.2: HTML 3.2
  • -1
  • 2
  • 3.2

Sample code invoking the htmlCodeFormat function

<cfset testString="This is a test & this is another <This text is in angle brackets> Previous line was blank!!!">   <cfoutput>#htmlCodeFormat(testString)#</cfoutput>   

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub