PasHi Pascal Highlighter

   
Release: 1.1.0
Date: 15 Feb 2010
O/S: All Windows 9x and NT versions (inc. XP, Vista & Windows 7)

Overview

Introduction to PasHi

Softpedia 100% Free symbol

PasHi is a simple command line program that syntax highlights Pascal source code. The highlighted code is output as XHTML.

The program reads Pascal source from its standard input, or the clipboard, and writes the generated XHTML to its standard output, or stores it on the clipboard. By default PasHi generates complete XHTML documents but it has the option to create XHTML code fragments containing just the highlighted code.

The ability to highlight code via the clipboard is the program's most unique feature and it makes PasHi very easy to use. You simply copy the required source code to the clipboard and run PasHi with the necessary parameters. The highlighted code will replace the original source on the clipboard ready for pasting into a document. This is particularly useful when combined with the option that creates XHTML fragments because it simplifies writing documents that contain several Pascal source examples.

The XHTML generated by PasHi uses Cascading Style Sheets (CSS) to format the highlighted source code. Complete XHTML documents contain an embedded style sheet but XHTML fragments require the user to provide a suitable style sheet.

The download includes a ReadMe file that explains the usage of the program and all its parameters. The file also has an explanation of the CSS classes required by PasHi-generated XHTML. An example style sheet is provided.

Change of Name
As from v1.1.0 PasH changed its name to PasHi because it became known that another open source project beat me to PasH.
Because the executable files also got renamed this may break some shortcuts or scripts. It also means that the renamed PasHiGUI will only communicate with PasHi.exe, so you must use executables from the same release.

Why Another Pascal Highlighter?

Simple, I needed an easy to use tool to format Pascal code for the DelphiDabbler website. I wanted the following:

  1. Cascading style sheets.
  2. Valid XHTML.
  3. Full control over the appearance of the output code.
  4. Ability to highlight via the clipboard.
  5. The option to generate XHTML fragments for inserting into existing documents.

On checking the available free tools I've found they were either too complex or didn't provide one of the features I wanted. I'd already written highlighter code for my CodeSnip program, so I extracted that, tweaked it and wrapped it up in a command line program. Having made it I thought I'd release it in case anyone else finds it useful.

PasHi In Use

Two sites that use PasHi for their syntax highlighting are:

Unsurprisingly PasHi is used for all Pascal highlighting on this site.

If you use PasHi to provide source code highlighting on your site please let me know and I'll add a link to you here.

Also get in touch if you would like to request new features.

GUI Front End

Now bundled with PasHi
As from v1.1.0 PasHiGUI has ceased to be distributed as a separate project and is now bundled with PasHi. The source code has also been merged into the PasHi repository.

PasHiGUI provides a user friendly graphical user interface for PasHi. Using PasHiGUI you can easily highlight Pascal source files by:

  • Opening the file in the usual way.
  • Dragging and dropping a file from Windows Explorer.
  • Copying and pasting a file from Windows Explorer.
  • Copying and pasting source code from a text editor.
  • Dragging and dropping text selections from a suitable editor.

Highlighted code is displayed in the main window in three formats:

  • Rendered XHTML – the highlighted code is displayed as it will appear in a browser.
  • XHTML source code – the XHTML source code emitted by PasHi.
  • The original unprocessed source code.

Here's PasHiGUI displaying some highlighted code as a fragment:

Screenshot of PasHiGUI

The resulting XHTML can be saved to disk or copied to the clipboard. PasHiGUI also supports PasHi's ability to generate XHTML code fragments.

PasHiGUI requires that PasHi is installed either in the same directory as PasHiGUI or is on the system search path.

Beta Testing

PasHiGUI is still in beta – and has been for a long time. It has been well tested in use but may contain bugs. Use at your own risk.

I'll try to keep the program in line with any new features added to PasHi.

Bugs & Feature Requests

Please do report any bugs and request features. Better still, grab the source and implement the changes yourself and tell me about them.

Use the online issue tracker to report bugs and suggest changes.