Syntax Highlighting for Gherkin (Cucumber Language)

Posted by Liam McLennan on Geeks with Blogs See other posts from Geeks with Blogs or by Liam McLennan
Published on Tue, 30 Mar 2010 00:35:14 GMT Indexed on 2010/03/30 6:43 UTC
Read the original article Hit count: 421

Filed under:

SyntaxHighlighter is the de facto standard for syntax highlighting on the web. I am currently working on a tool for publishing BDD specifications on the web and I want syntax highlighting. Unfortunately, SyntaxHighlighter does not support Gherkin, the language Cucumber and SpecFlow use to define BDD specifications. Writing new language parsers for SyntaxHighlighter is very easy, so I implemented one for Gherkin. Here is what a syntax highlighted Gherkin file looks like:

# A comment here

Feature: Some terse yet descriptive text of what is desired
	In order to realize a named business value
	As a explicit system actor
	I want to gain some beneficial outcome which furthers the goal

@secretlabel
Scenario: Some determinable business situation
	Given some precondition
	And some other precondition
	When some action by the actor
	And some other action
	And yet another action
	Then some testable outcome is achieved
	And something else we can check happens too

Like all SyntaxHighlighter brushes to use this one you need to install the brush (shBrushGherkin.js). I have also used a custom theme to get it just the way I wanted it (shThemeGherkin.css). If you would like to use my Gherkin brush you may download the code and example page.

© Geeks with Blogs or respective owner