|
articles
Adding PHP Syntax Highlighting Support to ViewCVS
Like many who use ViewCVS against a CVS repository, you may notice that PHP syntax highlighting support is missing. ViewCVS is able to use GNU Enscript which does support many widely used languages like perl, c, and java. This document describes how to add PHP syntax highlighting support to Enscript which can be integrated with ViewCVS to produce syntax highlighted PHP files. By default Enscript stores all of its syntax highlighting definitions in a file called enscript.st, which was located in /usr/share/enscript for me. You need to make sure that you are using the 1.6.2 of this file since I will be referring to it by line number. Open up enscript.st in your favorite text editor and scroll down to the 'namerules' container somewhere around line 1268. Insert the following line somewhere in the list to designate which file types to use PHP syntax highlighting on. /\.(php|php3)$/ php; Now move down to the 'startrules' container around line 1301 where we will tell Enscript when to begin using syntax highlighting when inside of a *.php* file. /^<\?php/ php; Now comes the actual definitions for the PHP syntax highlighting. Put the contents of this file somewhere in your enscript.st file, preferably somewhere near the bottom. Before you can actually see highlighted PHP files in ViewCVS, you need to make sure ViewCVS is setup to actually use Enscript. Open up your viewcvs.conf file and make sure that you have the following somewhere in the file: use_enscript = 1 Now you need to tell ViewCVS about your updated enscript.st file. Open up your lib/viewcvs.py file in a text editor and add the following to the enscript_extensions array. '.php' : 'php', If everything is working properly, you should now see syntax highlighted PHP files in ViewCVS. Awesome! Updates09/28/2004: Daniel Frederiksen kindly provided an updated enscript file with all of the latest PHP functions. For the Lazy...If you do not feel like editing these two files manually, feel free to use my version. |
|
|||||||