administration mode
Pssst...Ferdy is the creator of JungleDragon, an awesome wildlife community. Visit JungleDragon

 

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.

Share |

Comments: 4
Reviews: 1
Average rating: rating
Highest rating: 2
Lowest rating: 2

COMMENT: PETER VON STÍCKEL emailhomepagerating

NOV 20, 11:32:11

comment » The line numbering feature isn't very helpful, since it is part of the content. If I wanted to copy the code, I would have to manually edit out the line numbers. I've seen better ways to do it, where the line numbering is in the CSS instead. Since I mostly do LS, I use Julian's tool for it. «

COMMENT: FERDY

NOV 20, 11:42:47 AM

comment » Peter,

Agreed, this is no problem though as you can enable/disable line numbering in Highlight. «

COMMENT: JEFF CROSSETT emailhomepage

NOV 20, 12:18:28 PM

comment » That is pretty cool. There is also a too used by the YUI development team for their code example site.

http://code.google.com/p/syntaxhighlighter/ «

COMMENT: FABIAN ROBOK email

NOV 21, 17:22:08

comment » Cool, there's even a Notetab++ plugin ... «

RATE THIS CONTENT (OPTIONAL)
Was this document useful to you?
 
rating Awesome
rating Good
rating Average
rating Poor
rating Useless
CREATE A NEW COMMENT
required field
required field HTML is not allowed. Hyperlinks will automatically be converted.