Know Python? Help ColdFusion Get Proper Script Highlighting On GitHub

Know Python? Help ColdFusion Get Proper Script Highlighting On GitHub

Posted by Brad Wood
Feb 07, 2014 13:39:00 UTC

It's bothered me for a while, that GitHub and Gist don't have proper syntax highlighting for full-script CFCs like this one.  

They handle tags fine, and even do script inside of a <cfscript> tag, but just leave full script components as black text all the way down the page.

 ColdFusion has allowed all-script components since version 9 which was released 5 years ago.  I always just assumed that GitHub was aware of the problem and someone somewhere was hard at work resolving it.  Silly Me.

GitHub uses this Ruby library to determine what language a while is written in:

https://github.com/github/linguist

Which in turn uses this Ruby wrapper to spin up the syntax highlighter:

https://github.com/tmm1/pygments.rb

But that library is just a proxy to this Python library that actually does the color coding:

https://bitbucket.org/birkenfeld/pygments-main

It looks like there's already a ticket from 2012 to add support and Ben Riordan took a whack at it last year with no luck.  So I've forked the Pygments library, but know nothing of Python so I'm asking anyone who does to help me get this figured out.  Since script already works inside <cfscript> tags, it sounds like all the pieces are there-- we just need to properly identify script components and use the correct highlighter for them. Comment here or shoot me an E-mail if you'd like to help!

 


Tyson

I believe I have it working. I added a ColdfusionCFCLexer class to handle files with a cfc extension. It uses both the ColdfusionMarkupLexer (for tags) and the ColdfusionLexer (for script). I forked the repository, but I'm having trouble cloning it to my laptop. I'll try it again later and do a pull request for my changes.

Brad Wood

That's awesome Tyson. I had troubles cloning it before I noticed that it is actually a Mercurial repo so you can't use "git clone".

Brad Wood

Thanks Tyson for submitting a pull request for this. We'll see what they say!

https://bitbucket.org/birkenfeld/pygments-main/pull-request/283/issue-756-add-coldfusion-lexer-for-script/diff

Sean Coyne

So now that pygments-main has been updated, it looks like pygments.rb is using a version with those changes. I've submitted this pull request to linguist (https://github.com/github/linguist/pull/1405) that should get proper syntax highlighting on github for script components once they pull it in and deploy it to github.com.

Site Updates

Entry Comments

Entries Search