In Search of a Script Syntax Highlighter

One of my dubious schemes is to turn this site into some sort of a source code repository for various scripts and other code I deem useful for others or otherwise worthy of publication.

Having HTML be a rich text format, I wish my repository to, at the very least feature source code syntax highlighting for sources post on it, therefore I am looking for a tool to accomplish that task.

My criteria for the tool I’m looking for is as follows:

  1. It should allow converting source code to syntax-highlighted HTML.
  2. It should support a range of computer languages, including but limited to, Bash (Linux shell), Perl, Python, TCL, C, C++, PHP, XML and HTML.
  3. It should be primarily driven by a command line interface, a GUI may be a nice but unnecessary addition.
  4. It should work on Linux.
  5. It should be Free Software, or at the very least be Open Source.
  6. It should properly handle obscure syntaxes such as embedded scripts within HTML files or Bash expressions such as ${#array} or <<EOF.
  7. The output HTML should be suitable for pasting into Wordpres, and preferably HTML 4 or XHTML standard-compliant.

Apart from the above mandatory criteria for which I rather not have to settle, I’d rather the tool be customizable and extensible with regard to the languages it supports and the kind of HTML it outputs.

So far my search through the web have yielded only one tool which satisfies enough of my criteria for me to consider useful, that tool is Webcpp.

However, Webcpp includes several caveats and limitations that prevent me from using it:

  1. It states support for “sh” scripts which should be sufficient for highlighting most “Bash” scripts, however, it handles expressions such as ${#array} incorrectly regarding whatever follows the pound (#) sign as a comment.
  2. The generated HTML utilizes the deprecated <font> tag.
  3. Despite it`s use of <font> tags, Webcpp delegates all styling information to a block of CSS code which is output in separate from the body of code, therefore the HTML code yielded is unsuitable for inclusion in WordPress.
  4. The tool is not customizable enough to allow me to overcome its limitations.
  5. This may be a petty complaint, but IMO the tool’s command-line syntax does not fit in with common UNIX command line conventions.

I will continue my search, and hopefully find other tools, however, if all else fails, I may eventually consider ripping out VIM‘s syntax highlighting engine and converting it to my purpose.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s