Matthew J. Clemente

Working With Rouge for the First Time

Apr 29, 2016
2 minutes

When I started blogging with Jekyll, one of the projects that interested me was working on a CFML lexer for Rouge. It's been a while since I've written a post, so it seemed like a good time to just dive in, get my hands dirty, and see what happened. All I'm doing in this post is getting Rouge set up, so that I can start tinkering with it.

I wasn't sure exactly where to begin, but I did anyway, which I've found to be an effective strategy for learning new tech. I forked the Rouge repo and then cloned it locally:

$ git clone git@github.com:mjclemente/rouge.git

There are instructions on the Rouge readme.md for contributing, so I did my best to follow them. Because I had already set up Ruby with rbenv, I was able to just run bundle to install the dev dependencies. That went smoothly, and the result was:

Bundle complete! 10 Gemfile dependencies, 22 gems now installed.

The next step was to run rake, which, according to the docs, tests the core of Rouge. The tests ran successfully, and the result included this line:

Run `rackup` and visit localhost:9292/:lexer_name to visually test a lexer.

So, I tried running rackup and it didn't work:

-bash: rackup: command not found

I had to do a little digging to resolve this, but it seems like the issue was with my rbenv setup. I needed to manually run the rbenv init in order to get the new Gemfile dependencies, including rackup, added to rbenv's shims directory (and thereby accessible via my $PATH).


Update - 07/20/2016: For those running Cygwin, Jakub Klimek noted, in the comments, that he had to manually add rackup to PATH via his .bashrc: export PATH=$PATH:~/.gem/ruby/gems/rack-1.6.4/bin/


Once I restarted my terminal, the rackup command ran successfully, and I was able to visually access the lexers, like the one for html: http://localhost:9292/html

rouge html lexer preview

That's it for today - Rouge set up, ready to dig in to how the lexers work.