Thursday, April 18, 2013

Razor brush for Alex Gorbatchev's SyntaxHighlighter

While I was putting together a new blog post about customizing the Web API Help page I took a look at how to display code in Blogger. SyntaxHighlighter is a popular tool for highlighting code in your blog posts which uses Javascript files and CSS to modify code snippets.

I followed this quick guide to using SyntaxHighlighter with Blogger (tip: don't add script references to brushes that you're not using!) and was generally pleased with the results but sad that no Razor brush is available. After a quick dabble however I have created a quick and dirty Razor brush for SyntaxHighlighter which I hope people find useful!

Example razor syntax:


  1. Very userful! I use it in my blog thanks.

  2. Nice one. I was looking for it.

    Thank you :)

  3. Ya man! Very useful. Everyones got C# but they forget about the Razor highlighting in cshtml pages. I used it CMS where people can write views without needing to publish. THis helped me allot ! Thanks

  4. There's a bug in this brush script. Towards the end of the script is the line

    SyntaxHighlighter.brushes.Xml = Brush;

    This causes problems if you're referencing the XML brush on the same page.

    There's a simple fix: change that above line to

    SyntaxHighlighter.brushes.Razor = Brush;

    Presumably this bug has been introduced by the author copying the contents of the XML brush and then modifying it for the Razor syntax.

    Otherwise it's a great addition - my thanks to the author.

  5. it's greate i have been searching for months
    for my blog.

  6. hi i am getting
    Error parsing XML, line 91, column 33: The content of elements must consist of well-formed character data or markup.

    errors while saving my blogger template after addition of above razor brush
    please help me.