Search code examples
htmlsyntax-highlighting

What's the best way to add colored-sytax code snippets to a web page?


Is there a web gadget or service or some open source solution for doing this?

Or do people just hand-code this in the HTML?

I need to add some Ruby and Python code to a web page.


Solution

  • I think you're looking for something like GeSHi - The generic syntax highlighter. I've had a lot of success with this in the past, GeSHi supports a TON of languages. Not only is this useful for your own syntax highlighting on your web site, but I use the source files because they contain all of the language keywords (I need them for a text-editor I'm working on with syntax highlighting). It's been a godsend.

    If you specifically need just Ruby and Python highlighting, you may want to check out NetBeans. It has a feature to output your source code to an HTML page while keeping all of the coloured syntax.