2010-04-10 97 views
2

我正在寻找一种可以像使用IDE一样突出显示代码(Ruby,PHP,JavaScript ...)的工具,然后将代码导出为html格式,以便在打开代码看起来就像IDE一样。添加代码突出显示并导出到HTML的工具

+0

可能重复上code2html http://stackoverflow.com/search?q=highlight+code – 2010-04-10 11:38:35

回答

3

can do thisVim至少,用这个命令:

:TOhtml 
+0

http://stackoverflow.com/a/8557573/367456 – hakre 2012-12-10 04:21:02

1

是独立的编辑器,你可以简单地使用红宝石syntax宝石。这里是用户指南,这表明你正在寻找的功能的摘录:

require 'syntax/convertors/html' 

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

puts html 
3

您还可以使用code2html(project page)色源代码的HTML。

code2html file.c > code.html 
+2

注: “官方” 版本'生成HTML' - 现在已弃用的标签。我使用自己的版本生成CSS,取而代之。这个补丁的CSS版本可以在我的网站上下载:http://www.field-theory.org/software/index.html#code2html – user8472 2011-01-15 20:41:52

+0

+它的包装:http://ysgitdiary.blogspot.fi/2012 /07/code2html-sh-wrapper-for-create-folder.html – 2012-07-24 15:57:11

0

Textmate也可以做到这一点。请参阅TextMate包中的“从文档创建HTML”。

1

highlight_file会很快,虽然PHP只有解决方案。

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

除此之外 - 你试过GeSHi

相关问题