CHIP: Code Highlighting in PHP

CHIP is a simple source code highlighter designed to be used either on web-servers or from the command line. It takes C, C++, Java, Lisp, Python, PHP, HTML, or JavaScript code, and outputs an XHTML version of that code, with appropriate highlighting.

CHIP supports multi-style highlighting in one source file. PHP files will have PHP sections highlighted using PHP syntax, but will have embedded HTML sections not only rendered using HTML syntax, but also on a tinted background so that they are visually separated. JavaScript sections within the HTML sections will be tinted separately again, and of course highlighted using JavaScript syntax. An example is below, and links to further demonstrations are below that.

        chipFixLinks();                                        
1420  }                                                        
                                                               
    // -->                                                     
    </script>                                                  
    </head>                                                    
1425<body onload="javascript:chipOnload()">                    
    <?php echo pageHeader(); ?>                                
    <pre>                                                      
    <?php process(); ?>                                        
    </pre>                                                     
1430<?php echo pageFooter(); ?>                                
    </body>                                                    

In order that downloaders may access the unhighlighted version of the file, links to the plain text version are placed to the top and bottom of every highlighted file.

To protect against spambots, every email address and URL in the input file is obfuscated in the output, including the links to the plain text version of the highlighted file. This obfuscation is then corrected by a JavaScript function so that humans will see the correct entries. It is too expensive for spiders to execute JavaScript in their search for addresses, so this should stymie anybody who searches for email addresses.

CHIP is open source, licenced under The MIT Licence, and can be found on Freshmeat as the project "CHIP Code Highlighter".


Current Version

2.7.0.

Release Date

23 August, 2005.

Downloads

GitHub

Debian Archive (.deb)
MD5 Hash of .deb

Distribution Archive (.tar.bz2)
MD5 Hash of .tar.bz2