» Contents
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 [deprecated], 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 can be installed with the program. You can also create your own.
PasHi can either generate complete HTML documents or just fragments of HTML code. 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, a GUI front end for PasHi, is optionally included in the release. This provides a point and click way of using PasHi. Most, but not all, command line options are supported. Files and text can be dragged and dropped onto the program's window to highlight them.
» Contents
Details of how to install PasHi and PasHiGUI are provided in
the file ReadMe.txt that is included in the program download.
By default PasHi reads input from standard input and writes
highlighted output to standard output. You can process a single file and write
output to another file using shell redirection. For example, to highlight
source.pas and output to source.html use:
PasHi <source.pas >source.html
If you do not redirect output the resulting HTML is displayed on the console. If you don't redirect input then you must enter the source code manually on the command line, a line at a time. When you have finished you must signal end-of-file by pressing Ctrl+Z on a line on its own, followed by Return.
Note that PasHi's default behaviour can be altered by using a configuration file. See Configuring PasHi for full details.
PasHi's behaviour can be modified by specifying one or more file names and / or commands on the command line.
File names and commands can be intermixed. Deprecated: a later major release may require file names to be specified before the first command.
If one or more file names are entered on the command line then input is taken from the files. Source code is read from each named file in turn and concatenated before being highlighted. Standard input is ignored. Specifying a single file name has the same effect as redirecting standard input from that file.
If you specify file names on the command line you should not
use the --input-stdin or --input-clipboard commands.
No error will be reported if you do so, but the behaviour may not be as
expected.
Many commands have both a long and a short form, but some commands have only a long form. They are explained in the following table.
| Command | Description | |
|---|---|---|
| Long form | Short form | |
| --input-stdin |
Reads source code from standard input. Since standard input is the default input source, this command is provided mainly to restore the default behaviour if it has been overridden in the config file. This command should not be combined with |
|
| --input-clipboard | -r |
Reads source code from the clipboard. This command should not be combined with |
| --output-stdout |
Writes highlighted code to standard output. Since standard output is the default output destination, this command is provided mainly to restore the default behaviour if it has been overridden in the config file. This command should not be combined with either
|
|
| --output-file | -o |
Writes highlighted code to the file specified by the following parameter. Using this command has exactly the same effect as redirecting standard output to a file. This command should not be combined with either
|
| --output-clipboard | -w |
Writes highlighted code to the clipboard. All output is stored as Unicode text. Character set information is excluded from complete HTML documents. Do not combine this command with either |
| --doc-type | -d |
Determines the type of document to be output. All but one of the document types are complete HTML documents. The required document type is specified in the following parameter which must be one of:
|
| --branding | -b |
Switches on or off the inclusion of "branding" information in output documents. Branding means that the document contains code indicating that the document was generated by PasHi. In the case of
The short form of the command, |
| --language | -l |
Specifies the language used in the output document. A language code recognised by HTML must be provided in the parameter that immediately follows this command. The code is not checked. If this command is not supplied then no language information is included in the output file. This command has no effect if the |
| --language-neutral |
Indicates that no language information is to be included in output documents. Since this is the default behaviour this command is provided mainly to restore that behaviour if it has been overridden in the config file. |
|
| --title | -t |
Sets the title of the output document. The title text must be supplied in the parameter immediately following the command. Titles containing spaces must be enclosed in double quotes. This command has no effect if the |
| --title-default |
Indicates that the default title is to be used in the output document. Since this is the default behaviour this command is provided mainly to restore that behaviour if it has been overridden in the config file. This command has no effect if the
|
|
| --embed-css | -s |
Creates an embedded CSS style sheet in the output document. The CSS is read from the file whose name is specified by the parameter immediately following the command. The CSS must define the styles described below. If the file name includes no path information, e.g.
Do not combine this command with |
| --link-css | -k |
Specifies the URL of an external CSS file to be linked from the generated HTML file. The URL must be given in the parameter immediately following this command. The URL can be relative or absolute. The linked CSS file must define the styles described below. Since no CSS is embedded in the output file the
|
| --default-css |
Inidicates that the default style sheet is to be embedded in the output document. Since this is the default behaviour, this command is provided mainly to restore that behaviour if it has been overridden in the config file. This command negates both the |
|
| --hide-css [deprecated] |
-c |
Determines wheher embedded CSS code is wrapped in HTML comment tags
( In the case of
The short form of the command,
|
| --legacy-css [deprecated] |
Determines whether CSS classes in generated HTML documents revert to those used in PasHi v1 (legacy) or whether the new class names introduced in PasHi v2 are used. The next parameter must have one of the following values:
This command is provided for when you have to maintain code that uses the old CSS style names. New code should use the new class names. When using the |
|
| --inhibit-styling |
Enables styling for specified syntactic elements to be omitted from the HTML output. This is useful in reducing the size of HTML documents if you have elements that are not styled in any way. This command must be followed by a parameter which is either
the name of a syntactic element for which styling is to be prevented
or a set of zero or more syntactic elements. A set is a comma
delimited list of element names, enclosed in
Use Examples: To suppress generation of styling for white space only, use
|
|
| --encoding | -e |
Sets the character encoding used for output to that specified in the next parameter. HTML documents are marked with the chosen format and the resulting file may include byte order marks. Valid encoding parameters are:
This command is ignored if the |
| --trim | -m [deprecated] |
Determines if or how source code is trimmed of blank lines and spaces before highlighting. Multiple source files are trimmed individually before concatenation. In the case of
The short form of the command,
|
| --separator-lines |
Specifies the number of blank lines to insert between the contents of each source file. The required number of lines is given in the following parameter and must be in the range 0..16. The default value is 1. This command is ignored unless more than one file is specified on the command line. |
|
| --line-numbering | -n |
Determines whether line numbers are prepended to each line of source code in the output document. In the case of
The short form of the command, |
| --line-number-width | -i |
Determines the minimum width, in characters, occupied by line numbers. Line numbers are padded to this width if necessary, but longer line numbers are not truncated. The required width is given in the following parameter and must be in the range 1..6. The default value is 3. This command is ignored if line numbering is not enabled: see the
|
| --line-number-padding | -p |
Determines the padding character to be used when the number of characters in a line number is less than the available width. The required character is specified in the following parameter, which must be one of:
This command is ignored if line numbering is not enabled: see the
|
| --line-number-start | -z |
Determines the number of the first line in the listing, in the range 1..9999. The default value is 1. This command is ignored if line numbering is not enabled: see the
|
| --striping |
Determines whether alternate lines of source code in the output document are styled differently or appear the same. The next parameter must be one of the following values:
Each line of output is enclosed in its own |
|
| --viewport |
Determines the type, if any, of viewport meta-data that is written to a HTML document head section. The type of meta-data depends on the value the next parameter, which must be one of:
This command has no effect if the |
|
| --edge-compatibility |
Determines whether a Microsoft Edge IE compatibility meta tag is written to an HTML document head. The next parameter must be one of the following values:
This command has no effect if the |
|
| --verbosity |
Determines the amount of output PasHi writes to standard error while executing. The amount of output depends on the value of the next parameter, which must be one of:
|
|
| --quiet | -q |
Alias for the |
| --help | -h |
Displays a help screen. The remainder of the command line is ignored. |
| --version | -v |
Displays the program's version number. The remainder of the command
line is ignored, except for |
There are some commands inherited from PasHi v1 that are not listed above. They have now been superseded by other commands but are still supported for compatibility reasons. However they are now deprecated.
They are:
| Old command | Purpose |
|---|---|
| -rc [deprecated] |
Alias for the |
| -wc [deprecated] |
Alias for the |
| -frag [deprecated] |
Alias for the |
| -hidecss [deprecated] |
Alias for Note: the |
Normally PasHi takes text files as input, either via redirection to standard input or from files.
Byte order marks (BOM) are checked to determine the encoding of Unicode files. Supported encodings are: UTF-8, UTF-16 little endian and UTF-16 big endian. If there is no BOM then the file is assumed to be encoded in the user's default code page.
The exception to the above is when the --input-clipboard command
is used. The source code is then expected to be in Unicode.
PasHi uses the following exit codes:
0: The program completed successfully.
1: The program encountered an error and terminated. Examine the
error message written to standard error for details.
Perhaps the most common usage of PasHi is to read source code from the clipboard and replace it with a highlighted fragment. Here's what I do when pasting highlighted source into a web page:
PasHi --input-clipboard --output-clipboard --doc-type fragmentAlternatively you can use short forms or v1 commands to shorten this:
PasHi -r -w -d fragmentor
PasHi -rc -wc -frag [deprecated]
If you mainly use PasHi in this way you can configure PasHi to use those parameters by default. See the example below for details.
» Contents
If PasHi finds a file named config in the
%AppData%\DelphiDabbler\ directory when it
starts up, it is read. Any commands found in that file are used to change the
program's default state.
PasHi does not install a config file by default, so if
you need one you must create your own. You can do this either by creating a
new file or by copying and editing one of the sample scripts provided with
PasHi (providing you installed them).
The format of the config file is as follows:
Most of the long form commands listed in Using PasHi have an equivalent in the config file. Config
commands have the same name as the long form version except that the
leading "--" characters are omitted. For example, the equivalent
of the--doc-type command in the config file is
doc-type.
WARNING:
The --help and --version commands are
exceptions that have no equivalent config file command. If either
help or version are included in the config file
then PasHi will stop with an error every time it is run.
None of the short form commands can be used in the config file, and nor can any of the v1 style commands.
WARNING: Using a short form or v1 style command in the config file will cause PasHi to stop with an error every time it is run.
PasHi expects config to be a UTF-8 encoded text file. The UTF-8
byte order mark may be omitted from the start of the file if required. If your
text editor does not support UTF-8, confine yourself to valid ASCII characters
and all will be well.
Some example config scripts are optionally installed in the
%AppData%\DelphiDabbler\ directory. The sample
scripts are:
v1-default.css (provided) is
present in the same directory.
The example config files, where installed, will not appear in the
%AppData%\DelphiDabbler\ directory until after
PasHi has been run once.
As mentioned above, a common use for PasHi is to highlight source code from the clipboard as an HTML fragment and place the HTML back on the clipboard. Instead of using the necessary commands each time you run PasHi you can add the following to the config file:
input-clipboard output-clipboard doc-type fragment
Now all you need to do is enter:
PasHi
on its own on the command line and it will perform the required actions by default.
Be warned that if you do this, you will need to specify the
--input-stdin, --output-stdout and
--doc-type commands on the command line to revert to default
behaviour.
Another useful example is where you have a CSS file containing your desired
highlighting style that you always want to embed in your highlighted document.
To save you having to specify a --embed-css command each time you
run PasHi, simply put the command in config, something
like:
embed-css C:\CSS\my-style.css
Or, in the special case of the CSS files optionally installed with
PasHi in %AppData%\DelphiDabbler\,
omit the path information and use, for example:
embed-css twilight.css
If you prefer to link to your CSS file instead of embedding it, you can add
a line to config like:
link-css https://example.com/css/my-style.css
Should you now need to revert PasHi to using its default CSS you will
need to include --default-css on the command line.
All the highlighted HTML generated by PasHi is enclosed in a
<div> block that is given the class
.code-pascal. CSS may be defined for this class to provide any
required background, padding, margin or border for the entire code listing.
Each line of source code is enclosed in its own <pre>
block. This tag should have CSS associated with it to set the required (mono
spaced) font family and size. It is also used to set the spacing between lines
using the margin CSS property - usually set to 0.
There are further CSS classes that can be associated with each line. They are:
<pre> tag when all lines are to be
rendered the same, i.e. when code striping is switched off (see the
--striping command above). Provide CSS for this class if you
want to style the line, for example to draw a border.
<pre> tags in place of the
.line class in even and odd numbered lines respectively when
code striping is switched on (see the --striping command
above). .even-line and .odd-line must be styled
differently otherwise striping will have no visible effect. It is usual to
provide a different background colour for alternate lines – hence the
name "striping".
--line-numbering and related commands above).
.linenum can be used to set the font style and colour used for
the line number, along with the margin between the line number and source
code and any separating border. The font used should be mono spaced
otherwise the numbers may not line up correctly.
PasHi encloses every syntactic element within each line's
<pre> block in <span> tags. Each of
these tags is given a class name relating to the type of the element. CSS
defining the font style & weight, text decoration and colour for each
class should be provided. These classes are:
:= and >).
These CSS classes should be defined as children of .code-pascal
to avoid potential clashes with other similarly named styles in an HTML
document.
Whenever you need to define your own CSS style sheets to use with files generated by PasHi you must provide definitions for all the above styles. You will need your own CSS if you:
--embed-css switch.
--link-css switch.
--doc-type fragment command in another HTML file.
To help you get started in defining your own classes, here are the default definitions that are used by PasHi.
Note that this example also includes some additional class names [deprecated]. These relate to PasHi v1.x, as explained below the listing.
.code-pascal,
.pas-source {
background-color: transparent;
}
.code-pascal pre,
.pas-source pre {
font-family: "Courier New", monospace;
font-size: 9pt;
margin: 0;
}
.code-pascal pre.line,
.pas-source pre.line {
}
.code-pascal pre.odd-line,
.pas-source pre.odd-line {
}
.code-pascal pre.even-line,
.pas-source pre.even-line {
background-color: #f0f0f0;
}
.code-pascal .linenum,
.pas-source .linenum {
border-right: 1px silver solid;
padding: 1px 4px 1px 2px;
margin-right: 0.75em;
color: gray;
background-color: #f0f0f0;
}
.code-pascal .comment,
.pas-comment {
color: green;
font-weight: normal;
font-style: italic;
text-decoration: none;
}
.code-pascal .kwd,
.pas-kwd {
color: navy;
font-weight: bold;
font-style: normal;
text-decoration: none;
}
.code-pascal .ident,
.pas-ident {
color: black;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .sym,
.pas-sym {
color: black;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .str,
.pas-str {
color: blue;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .num,
.code-pascal .float,
.code-pascal .hex,
.pas-num,
.pas-float,
.pas-hex {
color: maroon;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .preproc,
.pas-preproc {
color: teal;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .asm,
.pas-asm {
color: black;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
.code-pascal .space,
.pas-space {
}
.code-pascal .err,
.pas-err {
color: black;
background-color: yellow;
font-weight: normal;
font-style: normal;
text-decoration: none;
}
Change the styles to suit your needs.
Note that PasHi v1.x and earlier used different CSS class names.
code-pascal was named pas-source while the
remaining classes had pas- prepended to the class name, for
example .kwd was .pas-kwd. If you want
PasHi to revert to using the old style names pass
"--legacy-css on"
[deprecated]on the command line or place
"legacy-css on"
[deprecated]in the config file
if you want to use the old style names by default.
PasHi provides several .css files that can be used to change the
style of highlighted code. They are (optionally) installed into the
%AppData%\DelphiDabbler\ directory when
PasHi is first run after installation. The files are:
† All the Delphi 2010 related files attempt to emulate the IDE code editor's left hand gutter when line numbers are displayed.
You can embed these files using the --embed-css command, followed
by the file name on its own with no path information. You can also configure
PasHi to always use one of the files by including a suitable
embed-css command in the config file. You may copy
and edit these files freely, and may use them on any website.
All the sample files support both legacy and new CSS class names.
» Contents
PasHiGUI provides a GUI for PasHi and permits many of PasHi's features to be accessed via a point and click interface.
PasHiGUI's main window displays two tabs: Display View and HTML view. These tabs provide different views of the generated HTML, as follows:
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. It is toggled on and off using the Options | Show / Hide Options Bar menu option or the "cog" button on the toolbar.
All PasHi options supported by PasHiGUI can be set from this side bar. Options are grouped under various collapsible sections. Each group relates to one or more PasHi commands. Select the required options and click the Apply button when ready. Any currently displayed document will then be regenerated using the new settings.
You can revert to PasHi's default settings, as modified by any config file. Click the Restore Defaults to do this. Clicking this button updates the options in the side bar but does not regenerate the current document. You need to click the Apply button to do this.
The options set in the side bar are recorded in a file when PasHiGUI closes. They are reloaded the next time the program is started. This means that you can keep a different set of "defaults" for PasHiGUI to those used for PasHi.
PasHiGUI is controlled by a main menu along with a toolbar that replicates some of the functions accessed via the menus. The menus are described below:
PasHiGUI supports the following drag and drop operations as a means of inputing source code to be highlighted:
PasHiGUI will not work unless PasHi is installed in the same directory and is the correct version. Using the installer to install both programs is the best means of ensuring that everything is set up correctly.
Commands, parameters, defaults, CSS styles and configuration files marked as deprecated are likely to removed in the next major release. In the main these are breaking changes: they won't be backwards compatible will the current version.