1. Georg Brandl
  2. pygments-main
Issue #756 resolved

ColdFusion Lexer doesn't work on script-only files.

Anonymous created an issue

As of ColdFusion v9 the language supports ColdFusion component files (*.cfc) that consist of cfscript exclusively. This is to say there are no tags in it whatsoever. The file begins with the keyword "component" and ends with the closing curly brace.

The built-in functions, operators, keywords, etc. found inside the script are all common to the language. No additional/special cases exist.

Comments (5)

  1. Anonymous

    I have looked through the source and it looks like I have a bit of learning curve. It appears that

    class ColdfusionMarkupLexer(RegexLexer):
    

    on lines 1512 through 1551 of pygments/lexers/templates.py should be modified.

    If anyone more familiar with python wants to make a quick and appreciated change essentially any file with the extension .cfc in which the first word is component - the whole file can be treated exactly the same as existing <cfscript> implementation defined by line 1531:

    (r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)',
                 bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
    

    I'll continue to look into it. I'm hung up on the fact that the word component has no closing statement. The coloring should just continue for the whole file regardless.

    example:

    component output="false" displayname="demo" {
        public function init(){
            sampleVariable = 'sampleValue';
            if(sampleVariable == 'sampleValue'){
                //do something
            } else {
                //do something else
            }
        }
    }
    

    should render the same as:

    <cfscript>
    component output="false" displayname="demo" {
        public function init(){
            sampleVariable = 'sampleValue';
            if(sampleVariable == 'sampleValue'){
                //do something
            } else {
                //do something else
            }
        }
    }
    </cfscript>
    
  2. Brad Wood

    Did anything ever become of this? The lack of CF script color coding has annoyed me for a long time but I've never actually dug around to see if there was a ticket until now. For projects like ContentBox CMS where ALL CFCs are in script, it makes them look like crap. I'd like to help too, but I don't know any Python.

    ColdFusion has supported all-script components since version 9 which came out 5 years ago.

  3. Log in to comment