jgiam.com

Just another WordPress weblog

Simple Syntax Highlight

without comments

I found out that using ‘<’ and ‘>’ within <pre> tags was illegal. So I started looking for a way to convert program code into HTML.

Later on, for my tutorial for my programming module, it involved putting code into a Microsoft Word file. Doing so was tedious. If I copied and pasted from my editor into Word, the text would be pasted as normal text, and Word would format it in, for example, Times New Roman. Plus, the syntax highlighting that was in the editor was gone.

So now, I wanted something that could syntax highlight my code as well.

I came across GeSHi – Generic Syntax Highlighter. It was exactly what I wanted.

I hacked up a simple interface so I could paste code and convert it easily, and so, created Simple Syntax Highlight. You can choose the language (I only added the more common ones), whether to display line numbers, use CSS, and display HTML source. This solved both my problems, since now I could paste my code in valid HTML in my webpages, and I could also paste my code into Word with a fixed-width font, and syntax highlighting.

I called this “Simple Syntax Highlight” because I intend to create a database-driven site in future, to store converted codes, maybe a comments-system as well. But that won’t be anytime soon, as I have my Uni work to cope with.

I welcome any feedback. If you spot a bug, do let me know as well.

Simple Syntax Highlight – http://jgiam.com/geshi/

Written by Jon G

February 7th, 2006 at 8:40 pm

Posted in Techie Corner

Tagged with

Leave a Reply