Delphi: Steven's Pascal to HTML converter
Version 1.20, 2014-07-24
I wasn't too happy with the Pascal to HTML converters I found on the web, so I decided to try and write my own converter. The basic principle is that it's CSS based. The program inserts “<span>” tags with class properties for each type of string: keywords, strings, numbers, comments and compiler directives. The program uses an HTML template file where it inserts the code, and which has default CSS definitions for the different classes.
The version number indicates that this is the first release version. I wrote the initial version in about a day and a half, and this means the following:
- that Delphi still is the RAD (Rapid Application Development) tool it advertised from its first version. (FTW the main source file of the initial version is just 373 lines long.)
- that, while it does its job, it's not (yet) the polished version you expect from e.g. commercial software,
Despite these incompletenesses I hope this tool will prove useful for anyone who wants his or her Pascal or Delphi code on a website.
Steven's Pascal to HTML converter can be downloaded here.
The program comes without an installer. Just unzip the files to the folder you prefer. Note that all files must go to the same folder.
Usage should be straightforward.
- The program starts with loading a Pascal keywords list from keywords.txt. If the file isn't found the user gets a warning that a built-in list will be used.
- Select a source file, or type its path in the edit box. A default destination location will be set, in the same folder, same filename, but with a .HTM extension instead of a .PAS extension.
- You can override the default destination file by selecting one or typing the path in the edit box.
- Click the "Create HTML" button to create the file. The program will insert the converted Delphi code in an HTML template, appropriately named template.htm. If the file isn't found the user gets a warning that a built-in template will be used.
Included is a keywords.txt file, listing the keywords of the Pascal language. Code highlighting is based on this file. That means that you can add or delete keywords if you like. I already added Delphi keywords not found in the Pascal language, like “private” and “public”.
The file template.htm contains the code to create a valid HTML5 document, and in which the converted Pascal code is inserted. The marker for this is the string “***insert***”. As you can see in the supplied template there may be other text on the same line, which is important for the use of the “<pre>” tag.
Template.htm also contains some sample CSS, which you can change at will, or move to an external file.
Version 1.20 dd. 2014-07-24
- Update: Vista style file dialogs
Version 1.10 dd. 2014-07-23
- New feature: Can use clipboard as source
- Bugfix: two successive quotes in string
- Update: default file for save file dialog
- Update: additional file types for open dialog
Version 1.0 dd. 2014-07-18
- Does multi-line comments
- Does hex numbers
- Fixed size for main form
- Review of generated HTML file added
- About box and readme file added
- Initial version
What does it cost?
Steven's Pascal to HTML converter is free software. However, if you're satisfied with the program and want to show your appreciation you can donate a small amount via Paypal.
Steven's Pascal to HTML converter may not be sold, but you're free to distribute it as long as the contents of the ZIP file remains unchanged.
I welcome your comments, bug reports, suggestions, and general feedback here.