tags:

views:

76

answers:

6

Hi there, I'm looking for a tool that can highlight code (ruby, php, javascript...) like with an IDE and then export the code to html format so that when opening the html page the code looks just like with the IDE

Thanks.

A: 

You can do this with Vim at least, with this command:

:TOhtml
Sirupsen
A: 

To be independent of editors, you can simply use the ruby syntax gem. Here is an excerpt of the user guide, which shows the feature you are looking for:

require 'syntax/convertors/html'

convertor = Syntax::Convertors::HTML.for_syntax "ruby"
html = convertor.convert( File.read( "program.rb" ) )

puts html
paradigmatic
A: 

Emacs supports exporting code to html using http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el

dominikh
+1  A: 

You can also use code2html (project page) to color source code.

code2html file.c > code.html
Michał Trybus
A: 

Textmate can do it too. See "Create HTML From Document" in the TextMate bundle.

Greg
A: 

highlight_file would be fast, although PHP only solution.

<?php highlight_file("somefile.php"); // basic usage
highlight_file(__FILE__);
$out = highlight_file("file.php") // string variable, can be written to file etc.
?>

Other than that - have you tried GeSHi?

eyescream