Command line tool for syntax highlight C # in HTML?

I am looking for an easy way to syntactically extract C # code in HTML from the command line. Ideally, this would be something like:

syntax-highlighter test.cs 

... produces test.html.

+7
source share
3 answers

You can try SyntaxHighlighter . This does not literally translate C # to the HTML source, but uses javascript instead. All you have to do is link to JS files. For example:

 <html> <head></head> <body> <pre class="brush: csharp;"> //put all your code here public class Hello1 { public static void Main() { System.Console.WriteLine("Hello, World!"); } } </pre> <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCore.css"></link> <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemeDefault.css"></link> <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.js"></script> <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushCSharp.js"></script> <script type="text/javascript"> SyntaxHighlighter.all(); </script> </body> </html> 

The result is very good.

It would be very easy to write a script that uses the above template and simply exposes the source code in the right place.

+1
source

Very nice pygments .

Team

 pygmentize -f html /path/to/test.cs 

Supports many languages, including C #. Requires python.

+4
source

Try GeSHi . This is a syntax shortcut for PHP, so you can write a very simple PHP command line script that takes the name as an argument and spits out the highlighted version.

+1
source

All Articles