How to publish gorgeous code »
FERDY CHRISTANT - NOV 20, 2007 (09:48:00 AM)
If you need to publish source code listing on the web, you probably have encountered the tedious work involved, such as code indenting and color coding keywords in HTML. I knew of at least one tool that can automate this for Lotusscript publishing, but have now found a more general tool that can handle all programming languages. It's called Highlight, and is available for all the major platforms.
Here's a demo. This is how source code used to look on this site:
Notice that there is no color coding. I also had to insert a lot of nbsp elements for the indenting. Using Highlight, I can now easily publish it like this:
00001 Sub Initialize 00002 Dim strCode As String 00003 strCode = | 00004 Dim strMessage as String 00005 strMessage = "I'm dynamic" 00006 msgbox strMessage | Execute( strCode ) 00007 End Sub
Notice also the line numbers, I can even make anchors of them. There's a multitude of other color schemes too, here's one:
00001 Sub Initialize 00002 Dim strCode As String 00003 strCode = | 00004 Dim strMessage as String 00005 strMessage = "I'm dynamic" 00006 msgbox strMessage | Execute( strCode ) 00007 End Sub
I will leave it to you to play with the other options. Finally, some instructions for Blogo users to publish output of the Highlight tool. The easiest thing to do is let Highlight generate HTML as output, and setting it up so that it creates the CSS styles inline. Then, open the output file, view the source and copy everything between the pre tags, including the pre tag itself. Next, open the HTML editor from the Blogo rich text editor and paste the code. Finally, publish your pretty code.



Comments: 4
Reviews: 1
Average rating:
Highest rating: 2
Lowest rating: 2
COMMENT: PETER VON STÖCKEL


NOV 20, 11:32:11
COMMENT: FERDY
NOV 20, 11:42:47 AM
Agreed, this is no problem though as you can enable/disable line numbering in Highlight. «
COMMENT: JEFF CROSSETT

NOV 20, 12:18:28 PM
http://code.google.com/p/syntaxhighlighter/ «
COMMENT: FABIAN ROBOK
NOV 21, 17:22:08