DP_ParseBBML CFML Custom Tag

Download | Revision History | Usage | Example Output | Resources

This ColdFusion 4.5+ CFML custom tag translates a simplified, HTML-like markup language called "BBML" (supported BBML tags) into valid HTML. BBML is based on the original UBBCode™ used in the very popular Ultimate Bulletin Board™ discussion application. Useful for online forums or content editing applications this gives end users some of the power of HTML without risking "damage" to the rest of the presentation.

The tag has the following features:

  • Support for a wide set of BBML formatting tags. See the full set of supported BBML.
  • BBML validation. The tag will not convert incomplete or badly formed tags.
  • Complex, nested list support with full support for all HTML ordered lists.
  • Optional HTML conversion in the input to "safe" character entities that will be displayed in a browser as HTML code.
  • Optional "Smiley" conversion that converts many common "smilies" or emoticons (such as ":^)") to graphics. Two sample sets of smiley graphics are included in the archive.
    • Sample Default smilies: , , , ,
    • Sample Blue Frog smilies (by Andy Jarrett): , , , ,
    • See the full list of supported smilies
  • The ability to revert converted HTML back to BBML code.
  • The abilty to color-code material in [code][/code] blocks as does ColdFusion Studio. This capability is provided by an integrated version of Dain Anderson's CF_ColoredCode tag. Used with permission.
  • The ability, via the [sql][/sql] tag, to bold reserved words of the SQL92 and SQL99 standards. This capability is provided by Jochem van Dieten.

Thanks to Craig from Cyber Creations Inc. for testing, support and suggestions, Dain Anderson from cfcomet.com for the use of CF_ColoredCode, Andy Jarrett of The Blue Frog Company for his contribution of alternate smilies, and Jochem van Dieten for his implementation of the [sql][/sql] tag.

Download back to top

This tag requires Macromedia's Cold Fusion development enviroment, version 4.5x or later. All downloads and code are covered by our Source Code Policy.

DP_ParseBBML.zip, 42.5kb Zip-format Archive

Revision History back to top

July 25, 2004 Version 1.1

  • Removed documentation from the downloadable archive to ease maintenance.

July 21, 2003: Version 1.1 Re-Release

  • Fixed a major, incredibly STUPID bug which caused errors in the absence of [code] or [sql] blocks. Thanks to Tony Monast for pointing this out.

October 6, 2002: Version 1.1 Release

  • Fixed a major bug which prevented lists from processing properly in CFMX.
  • Added the [sql][/sql] tag as implemented by Jochem van Dieten.

May 19, 2002: Version 1.0 Release

  • Added [code][/code] block code-coloring via an integrated version of Dain Anderson's CF_ColoredCode tag.
  • Added a new set of smilie graphics contributed by Andy Jarrett of The Blue Frog Company.
  • Several bugs fixed and some (minor) speed improvements.

March 31, 2002: Beta Two Release

  • Added the "RevertToBBML" attrbiute.
  • Added the "size" and "color" BBML tags.
  • Improved validation for images and links.
  • Improved handling of non-tag square brackets.

February 8, 2002: Initial Beta One Release

  • Initial Release

Usage back to top

The tag takes a string and converts BBML markup code to HTML, converts HTML markup to "safe" character entities, and converts common "smilies" to graphics.

Tag Usage

The DP_ParseBBML takes eight parameters:

InputThe input string to convert. Optional if an end tag exists.
OutputVarA valid ColdFusion variable name. Defaults to "DP_ParseBBML". The name to be used for the results structure.
ConvertSmiliesBoolean (Defaults to "No"). If "Yes/True" will convert supported smilies to HTML <img> tags. If "Yes" requires the "SmileyPath" attribute to be set.
SmileyPathA path to the directory where the smiley graphic set is relative to the template(s) calling the tag. Required if "ConvertSmilies" is set to "Yes". Examples are "/Art/Smilies/" and "../../Smilies".
ConvertHTMLBoolean (Defaults to "Yes"). If "Yes/True" will convert HTML tags in the input string to character entities. For example "<br>" will be converted to "&lt;br&gt;".
ConvertBBMLBoolean (Defaults to "Yes"). If "Yes/True" will convert all valid BBML code in the input string to HTML.
RevertToBBMLBoolean (Defaults to "No"). If "Yes/True" will attempt to convert all HTML code to BBML and will also ignore the values of "ConvertBBML", "ConvertSmilies", and "ConvertHTML".

There is no validation of this process. This feature was specifically added to revert BBML content previously converted to HTML with this tag. Using it on arbitrary HTML content is not recommended.
UseCF_ColoredCodeBoolean (Defaults to "No"). If "Yes/True" will attempt to color code all material within [code][/code] BBML blocks. This is a complex process and a performance hit should be expected.

Tag Output

The basic output of the tag is a structure named "DP_ParseBBML" (this name can be changed via the "OutputVar" attribute) containing the following keys:

InputString. The original input string, before conversion.
InputLenInteger. The length of the original input string.
OutputString. The converted string.
OutputLenInteger. The length of the converted output string.
ConvertSmilies"Yes" or "No". Same as the disposition of the "ConvertSmilies" attribute.
ConvertHTML"Yes" or "No". Same as the disposition of the "ConvertHTML" attribute.
ConvertBBML"Yes" or "No". Same as the disposition of the "ConvertBBML" attribute.
RevertToBBML"Yes" or "No". Same as the disposition of the "RevertToBBML" attribute.

If the tag has an end tag and the "Input" attribute has not been defined then the tag will convert anything contained in the tag and automatically output to the page. The DP_ParseBBML structure detailed above is still available.

Tag Example

The following examples show several methods of calling DP_ParseBBML.

<cfmodule template="DP_ParseBBML.cfm"
          ConvertSmilies="Yes"
          SmileyPath="\Smilies\">
Tag Input (BBML Code, HTML code, Smiley Code, etc)
</cfmodule>
<cf_DP_ParseBBML Input="#Form.Text#"
                 ConvertSmilies="Yes"
                 SmileyPath="\Smilies\">
                 </cf_DP_ParseBBML>
<cfoutput>#DP_ParseBBML.Output#</cfoutput>
<cf_DP_ParseBBMLmodule Input="#Form.Text#"
                       OutputVar="Conversion">
<cfoutput>#Conversion.Output#</cfoutput>

Example Tag Output back to top

The following BBML code:

[list]
[*][i]Italic Item[/i]
[*][link=http://www.depressedpress.com]Linked Item[/link]
[*]Item Three
[/list]

converts to the following HTML:

<p><ul><li><i>Italic Item</i></li><li><a href="http://www.depressedpress.com">Linked Item</a></li><li>Item Three</li></ul></p>

All supported BBML is detailed in this document.

Other Resources back to top

Other resources to help you make the most of this component including code walkthroughs and supporting systems and external web links.

  • BBML Example: A simple application that allows you to enter BBML code for DP_ParseBBML to convert to HTML.
  • BBML Codes supported in DP_ParseBBML: All of the codes supported in DP_ParseBBML with explanation and examples.
  • Ultimate Bulletin Board™: The original version of BBML, UBBCode™, was created specifically for this application.
  • phpBB: Another great forum application that uses a dialect of BBML (called "BBCode"). This is not only one of the best looking and performing forum applications out there it's also open source (but, alas, not ColdFusion). Definitely worth a look.
  • vBulletin: Another great PHP-based forum application that uses a dialect of BBML (this time called "vB Code").

32 Current Sessions; Time: 22:44:53 03-07-2009; Tick: 516