Google Search

Thursday, April 2, 2009

Code Snippets (2)

After I couldn't find a decent way to implement nice, colorful code snippets inside blogger (which holds me back from posing code related articles) as I mentioned in my last post, and after checking "CopySourceAsHtml" as suggested by Asher in his comment to my last post (and didn't like it - it creates HTML I really don't want to use), I decided to go on with writing my own converter.
I used the GOLD parsing system, along with the Calitha gold parser engine to parse source code of a given grammar (grammars for GOLD can be found here), added some metadata to that grammar (currently I've only done a proof-of-concept, so everything is hard-coded) that defines how to indent and colorize (HTMLize) it, and wrote this application:

(click to enlarge)

Next will probably be adding another language (C# - currently only tried it with XML), extracting metadata to external files (should see if I can merge it with the GOLD parser grammar files, and read it from there somehow), and making things look nicer, for starters.

The code is currently not available for download, but I'll probably start a project on sourceforge for that soon. I'll post an update when I will.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete