Syntax Highlighting

Syntax Highlighting

This is a syntax-colourer for HTML and PHP, written in PHP.

It dynamically produces coloured, styled HTML output from plain HTML/PHP source code on the server.

Colour categories

There are 25 configurable colour categories:

PHP HTML
  • Method
  • Keyword
  • String
  • Comment
  • Tags
  • Tags (background)
  • Punctuation
  • Brackets
  • Braces
  • Escaped character
  • Operator
  • Number
  • Variable
  • Constant
  • Text
  • Comment
  • Equals
  • String
  • Number
  • Entity
  • Argument
  • Parameter
  • Angle bracket
  • Tag Open
  • Tag Close
You can change the colours and font weights fairly easily. Look at the top of the source of the script and it should be fairly clear how to do this.

Resources

The script will highlight HTML from arbirary URLs.

However it will only highlight PHP scripts from beneath its parent directory. This limitation has been imposed for security reasons - it is important not to let visitors access arbitrary text files from your server.

Demonstrations

Page 1;

Page 1;

This page;

This site's front page;

Test page;

Test URL;

Test URL (offline).

To do

A great many things still need doing.

If you find bugs, please report them. If you know PHP, feel free to muck in.

Source code

The program renders its own source code.

License

This program and its source code have been placed in the public domain.


Index | Links


tim@tt1.org | http://mandala.co.uk/