With the lexer already written, the rest was fairly straightforward — mostly just grabbing the snippet from the DOM and surrounding each token with the correct CSS class.
Here's some example HTML that demonstrates how to use it to highlight a snippet of Ruby:
This would render the following:
SyntaxMarker is still a work in progress, but the core functionality is there. At this point, all that needs to be done is to add support for more languages. This is as simple as writing some regular expressions for language keywords, identifiers, etc.
Again, it was neat to see that most of the actual work is done by the lexer. From there, we can use the resulting tokens for many different purposes.