5 Useful tools to convert your entire code into Colorized and browsable HTML

written by aext on October 23, 2008 in Resources with 5 comments

When you open your blog for sharing code, writing programming tutorial, publish a entry about codes, you should colorize, it called convert the entire code into colorized and make browsable with HTML. There are so many ways to do that, you can copy the code into web page design program and make up your code, but you don’t know what’re the easy ways to do that thing.

1- Use syntaxhighlighter:

This tool base on java script and stylesheet, the most popular Syntax Highlight tool in the internet, WordPress is now using this tool to highligh the code embebed.
Homepage: SyntaxHighlighter in Google Code
Download: syntaxhighlighter
Usage: manual

I like this tool because it will automatic convert the code after the web browser loaded. Because that, the code will not be formated and you can edit it later easily.

It support so many language: PHP, SQL Query, Java, Python, C# …..It’s cool, right?

2- Using PHP’s Built-in Source Highlighter:

PHP offer two functions for highlighting PHP code: highlight_file() and highlight_string(). Both functions return the same results, but each has its own specific input parameters. As their names suggest, the first function takes the filename of the PHP script whose code is to be highlighted, while the second takes the input as a string.

A Quick Example
Let’s take a look at an example of the highlight_string() function in action:

<?php
include_once 'init.inc.php';

if (!empty($_POST['text'])){
   echo '<div style="border: solid 1px orange; padding: 20px; margin: 20px">';
   highlight_string($_POST['text']);
   echo '</div>';
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
   <textarea name="text" style="width: 300px; height: 200px"><?php
       echo @$_POST['text'];
   ?></textarea>
   <br />
   <input type="submit" />
</form>

This script displays a simple textbox into which you can type or paste the PHP code you want to highlight.

3- Java2HTML Converter (for java blog):

This is also cool converter. Java2Html was write with java language, it converts Java (and other) source code (complete files or snippets) to HTML, RTF, TeX and XHTML with syntax highlighting.
Homepage: Java2HTML Converter
Download: download here

Java2HTML can be used as Eclipse plugin and it’s useful for fastly convert in time.

However, after converted, the code will be formated and it’ll hardly to edit later if you want to updated your entry.

4- CodeColorizer: Free Tool to Colorize Code in HTML or RTF.

This application allows you to generate HTML or RTF so you can colorize:

  • C#, VB.NET, J#, Javascript, Cobol, Algol
  • HTML, XML, XSLT, .Config
  • T-SQL
  • CSS, and many more…

Homepage: CodeColorizer
Download: download here
Things to notice is that it generates the simplest Html possible to achieve the right formatting. It colorizes in the same place ASP.NET code, HTML, C# code, javascript code, CSS styles, and more…

5-Csharpfriends.com Online Code Formatting:

Online site formatting with following code: C#, VB.NET, J# and T-SQL.
Its useful for who dont want to install any program into computer and dont need to add any code into webpage to do automaticlly, you just do it online, copy and go back to your working
Link to converter: CSharpfriend Online Code Fomartting

If you found some webpages or tools can do something like that, please correct me. Pleased to make you work perfectly.