Skip navigation.

"Once" By NightwishAll recent postsWeb Standards Solutions: The Markup and Style Handbook

T-SQL Coloring Is Now Available

T-SQL was the last on the list of languages I wanted to add to my code coloring tool. I work with SQL Server on an almost daily basis but I never realized there were so many reserved keywords, functions, system stored procedures, etc. On the other hand, highlighting T-SQL proved to be much easier than CSS.

I'm not shooting for quantity, but quality here. I wanted to add most languages web developers work with the most. I have no experience with PHP, Python or Perl which is why their support is missing. It's not that I don't acknowledge their existence. If anyone is willing to give me a hand with them I'll be grateful. The code highlighter tool is 100% Regex driven so Regex is the name of the game here.

The tool generates the least amount of overhead markup compared to similar tools I found online (no pun intended), but I'd like to optimize it ever more. For example, if two keywords come one after another each is colored separately. Ideally, I'd need to combine the two.

Any other suggestions? Comments?

Comments

Comment permalink 1 Ryan Farley |
Milan,

First of all, execellent work. Second, while I agree in the separation of content and presentation, the problem with having the external css to define the colors makes it so when you post code to a blog, that the css is not recognized by an RSS reader subscribed to the blog. It would be cool to have an option to include the style in the span tags instead of the external css for those times when it might make more sense. Just an idea.

Thanks, Ryan
Comment permalink 2 Steele Price |
Nice tool, been using Manoli's similar tool for a while.

I have found a bug in your regex for VB, the following test:

Case "", "1/1/1900"

results in inaccurate coding until another "" is found, I'd really like to see an implementation for this in a SQL Function or maybe a user control, I might do it later when I have some time because I'd like to be able to store the raw code in a blog post without any formatting then be able to tag it on the fly when retrieving the post. It offer a little more flexibility for me, not sure if everyone would agree that is a better way to implement the solution though.
Comment permalink 3 Milan Negovan |
Ryan: interesting thought. I did realize the other day RSS aggregators didn't pull down styles (which made sense). I'll try to find a compromise...

Steele: good catch. Fixed. ;) Once the code is stable I can bake it into an HttpHandler, for example, so you'd be able to color code on the fly. Or I will simply make the assembly itself available for download along with the source code.

Speaking of bugs... Do y'all remember Orkin commercials? The ones with a bug crawling across the screen in the middle of a commercial? An Orkin guy told us people were calling them demanding they repair their TVs! Serious! Some people would smack their TV seeing a bug. LOL!
Comment permalink 4 Jeff |
Milan,

Do you plan on releasing the source code for the Code Highlighter?
Comment permalink 5 Milan Negovan |
Yes, I do, but I don't have a specific timeframe in mind yet. I've purchased a separate domain, www.AspNetTools.com, where I will transfer all my tools along with source code, revisions, history, etc, some time down the road. I'll definitely announce it in my blog when it happens. ;)

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):