ColdFusion Brush for SyntaxHighlighter Plus and Evolved

SyntaxHighlighter Plus has been replaced by SyntaxHighligher Evolved. Instructions for adding a ColdFusion brush to both are below.

SyntaxHighlighter Plus is a great WordPress plugin for highlighting code in your blog posts. Out of the box it doesn’t come with a brush for ColdFusion syntax highlighting. A brush is a javascript file that is used by SyntaxHighlighter Plus to determine how to style the code inside the syntax highlighter itself. You could use the HTML brush for ColdFusion code, but a little funkiness happens at times so I added my own brush for ColdFusion.

How to Add the Brush

For Plus and Evolved, add the shBrushColdFusion.js to the scripts folder. If you installed it as a WordPress plugin, the folder structure will be syntaxhighlighter-plus (Plus) or syntaxhighlighter (Evolved), syntaxhighlighter, scripts.
SyntaxHighligher Plus: Modify the syntaxhighlighter.php found in the syntaxhighlighter-plus folder by adding ‘ColdFusion’ => array(‘coldfusion’, ‘cf’), to the aliases array.

$this->aliases = apply_filters( 'agsyntaxhighlighter_aliases', array(
            'Bash'      => array('bash', 'sh', 'shell'),
            'ColdFusion' => array('coldfusion', 'cf'),
            'Cpp'       => array('cpp', 'c', 'c++'),
            'CSharp'  => array('c#', 'c-sharp', 'csharp'),
            'Css'     => array('css'),
            'Delphi'  => array('delphi', 'pascal'),
            'Diff'    => array('diff', 'patch'),
            'Groovy'  => array('groovy'),
            'Java'    => array('java'),
            'JScript' => array('js', 'jscript', 'javascript'),
            'Perl'    => array('perl', 'pl'),
            'Php'     => array('php'),
            'Plain'   => array('', 'plain', 'text'),
            'Python'  => array('py', 'python'),
            'Ruby'    => array('rb', 'ruby', 'rails', 'ror'),
            'Scala'   => array('scala'),
            'Sql'     => array('sql'),
            'Vb'      => array('vb', 'vbnet', 'vb.net'),
            'Xml'     => array('xml', 'html', 'xhtml', 'xslt'),
        ) );

SyntaxHighligher Evolved: Modify the syntaxhighlighter.php found in the syntaxhighlighter folder by adding a registration for the brush in function _construct().

wp_register_script( 'syntaxhighlighter-brush-coldfusion',       plugins_url('syntaxhighlighter/syntaxhighlighter/scripts/shBrushColdFusion.js'),       array('syntaxhighlighter-core'), $this->agshver );

Add ColdFusion to the list of aliases.

'coldfusion'    => 'coldfusion',
'cf'            => 'coldfusion',

How to Use the ColdFusion Brush

Wrap the code you want to display in your post using one of the following methods:

[sourcecode language=’coldfusion’]code here[/sourcecode]
[sourcecode language=’cf’]code here[/sourcecode]
[coldfusion]code here[/coldfusion]
[cf]code here[/cf]

Personally I like the last method the best.


ColdFusion brush javascript code (change extension to .js before uploading)

No related posts.

10 Comments

  • May 23, 2009 - 2:57 pm | Permalink

    Good job on the CF brush? Would you mind me including it into the next release?

  • May 23, 2009 - 3:52 pm | Permalink

    @Alex
    Yes, feel free. And thank you for making the SyntaxHighlighter available in the first place.

  • May 27, 2009 - 5:41 am | Permalink

    I struggled for ages with another developer’s custom brush for cfml, but your instructions were clear and concise.
    It worked right away.
    Already applied to my site.
    Thanks so much.

  • May 27, 2009 - 7:18 am | Permalink

    @amclean

    You’re welcome!

  • Pingback: ColdFusion Brush For SyntaxHighlighter Evolved | Drewcorp Coding

  • June 13, 2009 - 6:16 am | Permalink

    Very clear explanation, after a little struggle I got it to work. I got the shBrushColdFusion.js file from another source (Google code) and that gave me the error message “Can’t find brush for: cf”.

    Using your explanation and your source file it all worked fine. Thanks a bunch!

  • Pingback: Adding new languages to SyntaxHighlighter Plus « Peter Cossey

  • September 21, 2009 - 8:50 pm | Permalink

    Excellent brush, really! I added your brush to my ever increasing list of bundled and non-bundled SyntaxHighlighter brushes (http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/) and would like to ask you whether I can either put a direct link to a *.js file, or make a copy of your code and place it on my server for convenience download

  • September 21, 2009 - 9:04 pm | Permalink

    @Abel
    Thank you. Feel free to do whatever you would like with the file. It’s free to use any way you wish.

  • Kerr
    January 4, 2011 - 3:15 pm | Permalink

    Thanks very much for the CF brush, it's nice to have keyword and function highlighting! I'm having trouble, however, with multiline comments where the commented text for the first line is highlighted correctly, but subsequent lines are not. Is anyone else experiencing this issue?

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>