Blog Post

Quick tip: format source code in html

,

I run a technical blog, so it is necessary to put code in almost every post. Most of the GUIs we use to do our work (let's say SSMS or Visual Studio) already provide this functionality, but when you copy and paste the code to the blog, you need to format it first, to pass from this:

DELETE FROM database1.schema1.table1 WHERE column1=valuex
/* generic comment */
SELECT * FROM database2.schema2.table2 WHERE column2=456

To this:

1
2
3
DELETE FROM database1.schema1.table1 WHERE column1=valuex
/* generic comment */
SELECT * FROM database2.schema2.table2 WHERE column2=456

These are some sites I use:

http://hilite.me/ 

My site of choice, it supports several languages and you can select predefined styles and customize them on-site.

http://poorsql.com/

Only for SQL, it provides a more robust keyword detection, but the format and customization is more limited, it also offers some obfuscation options.

http://www.dpriver.com/pp/sqlformat.htm

Also a good option, supports various languages, but a little bit more complex to use than hilite.me

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating