A place for my programming projects and the occasional blog about technology related matters.
Syntaxhighlight
Google Code Page - Source Code
This is a small class library written in C# to highlight code. I made this mainly because I wanted to try writing a parser. The library is designed to be extendable. The parser is not coupled to the formatting itself, you can use different formatters, all they have to do is implement a ISyntaxFormatter interface. Included are a HtmlInlineFormatter which surrounds each highlighted token with a <span style=”…”> and a HtmlCssClassFormatter which surrounds the tokens with a <span class=”…”> and defines the styles in css classes. At some point I’ll try to create a rtf formatter. Definitions for different languages are kept in xml files and are easy to make.
To test the highlighter I made a little proof-of-concept web application called SvnBrowser. It basically acts as a proxy for Subversion repositories, fetching the code files, highlighting them, and then writing them out. You can see it in action for Syntaxhighlight’s own repository at http://tech.einaregilsson.com/svnbrowser .
Note: On this site I don’t actually use my own syntaxhighlighting library to highlight code in the blog posts
. Instead I use the excellent highlight.js which is a javascript syntax highlighter.
Comment