ANN: A new Clojure brush for syntax highlighter

74 views
Skip to first unread message

Andrew Brehaut

unread,
Nov 19, 2011, 4:46:03 PM11/19/11
to Clojure
I have written a new brush for the javascript Syntax Highlighter to
replace sh-clojure. Rather than using the typical regex system, it has
a full parser and simple form annotator. This should result in
significantly better highlighting than earlier brushes.

You can find the project at https://github.com/brehaut/inc-clojure-brush.
It's running on my blog, frinstance http://brehaut.net/blog/2011/ring_introduction
and http://brehaut.net/blog/2011/l_systems

Key features:

* The head of every list is handled as either a function or method
call. No need for a list of clojure.core tokens.
* Comments, (comment …), and #_ all supported.
* Local variables in common core forms are highlighted.
* Meta data and quoted forms have additional styling.

Sean Corfield

unread,
Nov 19, 2011, 9:11:03 PM11/19/11
to clo...@googlegroups.com
On Sat, Nov 19, 2011 at 1:46 PM, Andrew Brehaut <abre...@gmail.com> wrote:
> You can find the project at https://github.com/brehaut/inc-clojure-brush.
> It's running on my blog, frinstance http://brehaut.net/blog/2011/ring_introduction
> and http://brehaut.net/blog/2011/l_systems

Very nice! I see it highlights mismatched parentheses too:

(use '[net.cgrand.moustache :only [app delegate]]))

Double parentheses - the last one is highlighted red.

I'll have to figure out how to integrate it into the blogging software
I'm using...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Daniel Solano Gomez

unread,
Nov 20, 2011, 9:25:48 AM11/20/11
to clo...@googlegroups.com

Looks nice. I think I may just deprecate my project in favour of this
one, especially since I don't really have the time to update it these
days.

One idea that just occurred to me is that there may be a chance to
leverage ClojureScript for this. I am not a ClojureScript (or
Javascript) expert, but it seems to me that using the ClojureScript
reader could help.

Nice work.

Daniel Solano Gómez

signature.asc

Andrew Brehaut

unread,
Nov 21, 2011, 7:53:40 PM11/21/11
to Clojure

On Nov 21, 3:25 am, Daniel Solano Gomez <cloj...@sattvik.com> wrote:
> One idea that just occurred to me is that there may be a chance to
> leverage ClojureScript for this.  I am not a ClojureScript (or
> Javascript) expert, but it seems to me that using the ClojureScript
> reader could help.

I've wondered about that too; I chose to write it in javascript
because i know it fairly well and knew i could get it running fast.
However, the design I chose (which collects tokens into the s-exp
tree, i.e. so that comment forms can have their parens highlighted)
would mean that even with Clojurescript, I wouldn't be able to
leverage the reader. There might also be ordering problems with maps
and sets using the reader?

Andrew Brehaut

Reply all
Reply to author
Forward
0 new messages