Syntax highlighting in Drupal

As I tool this site up for blogging about dev stuff, I wanted to test this easy-looking syntax highlighter. Let's give her a whirl, shall we?

[Update: I'm now using Google's Prettify, instead]

using System.Web.Mvc;
 
namespace Web.Controllers
{
    [Authorize]
    public class MainController : BaseController
    {
        public ActionResult Default()
        {
            return View();
        }
    }
}

Sexy, ain't it?

And, it was dead easy. Just download Alex Gorbatchev's excellent Javascript Syntax Highlighter, and unpack it into /sites/all/libraries. Then, download and install the Syntax Highlighter module for Drupal, and it will find the library and let you configure stuff right within Drupal, including which brushes to load (brushes are language-specific highlighting dictionaries).

Additionally, you can add this functionality right into your favorite WYSIWYG editor, though I haven't gotten that far, yet. Maybe that's for another post.

Comments

There are no comments

Add your comment