PasHi Pascal Highlighter

Release: 2.0.0
Date: 22 September 2016
O/S: All Windows versions


Introduction to PasHi

PasHi PasHi is a fully featured command line program that highlights Pascal source code. It reads the original source code from standard input, files or the clipboard and writes the highlighted code as HTML to standard output, a file, or the clipboard.

HTML 4, XHTML and HTML 5 are all supported. CSS is used for styling. Style sheets may be external or can be embedded in the HTML document. Several predefined style sheets may be installed with the program. You can also create your own.

PasHi can either generate complete HTML documents or just fragments of HTML code. Output files can be in UTF-8, UTF-16, ISO-8859-1 or Windows-1252 format.

HTML fragments make it easy to embed highlighted code in existing web pages. Web page authors simply need to ensure that the necessary CSS classes are available. The easiest way to do this is to use an external style sheet.

PasHiGUI, an optional GUI front end for PasHi, is included in the release. This provides a point and click interface to PasHi. Most, but not all, of PasHi's command line options are supported. Files and text can be dragged and dropped onto the GUI to highlight them.

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 HTML fragments because it simplifies writing documents that contain several Pascal source examples.

A user guide is installed with the program that explains the usage of the program and all its parameters. The user guide also has an explanation of the CSS classes required by PasHi-generated HTML. If PasHiGUI is installed the user guide can be displayed from PasHiGUI's help menu.

Why Another Pascal Highlighter?

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

  • Generated conformant XHTML or HTML 5 code.
  • Styled the HTML using cascading style sheets.
  • Provided full control over the appearance of the resulting document.
  • Had the ability to highlight via the clipboard.
  • Could optionally generate HTML code fragments for inserting into existing HTML documents.

On checking the available free tools I found that they were either too complex or they didn't provide all the features I wanted.

I had 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 found it useful. Since then it's been greatly enhanced.

GUI Front End

PasHiGUI provides a user friendly graphical user interface for PasHi. It supports most, but not all, of PasHi's features. Using PasHiGUI you can easily highlight Pascal source files by:

  • Opening the file in the usual way via a diaogue box.
  • 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.

PasHiGUI's main window displays two tabs: Display View and HTML view. These tabs provide different views of the generated HTML.

Display View renders the HTML as it will appear in a browser. If the generated code is a complete document it is displayed as-is. If it is a fragment the code is displayed using PasHiGUI's built in style sheet. The resulting HTML can be saved to disk or copied to the clipboard.

HTML View displays the generated HTML source code.

PasHi's behaviour is customised using the Options Side Bar. This can be displayed on the right hand side of the main window when required. All PasHi options supported by PasHiGUI can be set from this side bar.

The following screenshot shows PasHiGUI displaying some source code highlighted in Delphi 2010's "Twilight" style with line numbering enabled. The Options Side Bar is visible.

Screenshot of PasHiGUI

PasHiGUI requires that PasHi is installed either in the same directory as PasHiGUI. The install program takes care of this.