This document describes GNU a2ps version 4.13. The latest versions may be found on the a2ps home page.
We tried to make this document informative and pleasant. It tries to be more than a plain reference guide, and intends to offer information about the concepts or tools etc. that are related to printing PostScript. This is why it is now that big: to offer you all the information you might want, not because a2ps is difficult to use. See Glossary, for technical words or even general information.
Please, send us emailcards :)
. Whatever the comment is, or if you
just like a2ps, write to Miguel Santana and Akim Demaille.
The format used is nice and compact: normally two pages on each physical
page, borders surrounding pages, headers with useful information (page
number, printing date, file name or supplied header), line numbering,
pretty-printing, symbol substitution etc. This is very useful for
making archive listings of programs or just to check your code in the
bus. Actually a2ps is kind of bootstrapped: its sources are frequently
printed with a2ps :)
.
While at the origin its names was derived from "ASCII to PostScript", today we like to think of it as "Any to PostScript". Indeed, a2ps supports delegations, i.e., you can safely use a2ps to print DVI, PostScript, LaTeX, JPEG etc., even compressed.
A short list of features of a2ps might look like this:
Ogonkify
(see top),
written by Juliusz Chroboczek.
We try hard to make a2ps portable on any Unix platform, and bug free. But sometimes there can still be bad surprises, even after having compiled and checked a2ps on several very different platforms.
You may encounter some of these problems yourself. In any case, please never abandon without giving us a chance. We need information from everybody so that mistakes get fixed as fast as possible.
So, if you have a problem (configuration error, compilation error, runtime error, documentation error or unclear), first check in the FAQ (see FAQ), then on the page Known a2ps Bugs if the issue has not been addressed yet. If it is not the case, but it appears that the version of a2ps you have is old, consider upgrading.
If the problem persists, send us a mail (bug-a2ps@gnu.org) which
subject is a2ps version: short-description
and which
content mentions the name of your machine and OS, the version of
a2ps, every detail you have on your compiler, and as much traces as
possible (the error messages you get on the screen, or the output of
make
when it fails etc.).
Be sure to get a quick answer.
There is a mailing list in which are discussed various topics around a2ps: a2ps@gnu.org. There are also announcements about the version in alpha testing, requests for comments, new sheets, etc.
To subscribe to the list, send a mail to a2ps-request@gnu.org,
with subscribe
in the body.
Please, note that the mailing list is by no means a bug reporting address: use bug-a2ps@gnu.org instead.
If you like a2ps and if you feel like helping, there are several things you can do.
So we need beta-testers! To be one is fairly simple: subscribe
to the mailing-list where the betas are announced and distributed.
GNU gettext
which means that all
the messages can be translated, without having to look at the code of
a2ps: you don't need to be a programmer at all. All the details are
available on the a2ps translation page.
This chapter is devoted to people who don't know a2ps yet: we try to give a soft and smooth introduction to the most useful features. For a reference manual, see Invoking a2ps. For the definition of some words, see Glossary, for questions you have, see FAQ.
To print a file doc.txt
, just give it to a2ps: the default
setting should be the one you'd like:
gargantua ~ $ a2ps doc.txt [doc.txt (plain): 9 pages on 5 sheets] [Total: 9 pages on 5 sheets] sent to the default printera2ps sent the file
doc.txt
to the default printer, writing
two columns of text on a single face of the sheet. Indeed, by default
a2ps uses the option -2
, standing for two virtual pages.
Say you want to print the C file bar.c
, and its header
foo.h
, on 4 virtual pages, and save it into the file
foobar.ps
. Just hit:
gargantua $ a2ps foo.h bar.c -4 -o foobar.ps [foo.h (C): 1 page on 1 sheet] [bar.c (C): 3 pages on 1 sheet] [Total: 4 pages on 2 sheets] saved into the file `foobar.ps'
The option -4
tells a2ps to make four virtual pages: two rows by
two columns. The option -o foobar.ps
(which is the short version of
--output=foobar.ps
) specifies the output file. Long options
must always be separated by spaces, though short options with no
arguments may be grouped.
Note too that the options may be specified before or after the files, it does not matter.
If you send foobar.ps
to a printer, you'll discover that the
keywords were highlighted, that the strings and comments have a
different face. Indeed, a2ps is a pretty-printer: if it knows the
(programming) language in which your file is written, it will try to make
it look nice and clear on the paper.
But too bad: foo.h
is only one virtual page long, and
bar.c
takes three. Moreover, the comments are essential in those
files. And even worse: the system's default printer is out of ink.
Thanks god, precious options may help you:
gargantua $ a2ps -4 -Av foo.h bar.c --prologue=gray -P lw [foo.h (C): 1 page on 1 sheet] [bar.c (C): 3 pages on 1 sheet] [Total: 4 pages on 1 sheet] sent to the printer `lw'
Here the option -A
is a short cut for the option
--file-align
which specifies how different files should be
separated. This option allows several symbolic arguments:
virtual
, rank
, page
, sheet
(See Sheet Options, for more details). The value virtual
means not to
start each file on a different virtual pages.
So to fill the page is asked by --file-align=virtual
, or -A
virtual
. But symbolic arguments can be abbreviated when there are no
ambiguity, so here, you can just use -Av
.
The option -P lw
means to print on the printer named lw
,
and finally, the long option --prologue
requires the use one of
the alternative printing styles. There are other prologues (See Input Options, option --prologue
), and you can even design yours
(see Designing PostScript Prologues).
There are three special printers pre-defined.
The first one, void
, sends the output to the trash.
Its main use is to see how many pages would have been used.
gargantua ~ $ a2ps -P void parsessh.c [parsessh.c (C): 33 pages on 17 sheets] [Total: 33 pages on 17 sheets] sent to the printer `void'
The second, display
sends the output to Ghostview
, so that
you can check the output without printing. Of course if you don't have
Ghostview
, it won't work... And it is up to you to configure
another displaying application (see Your Printers).
The last, file
saves the output into a file named after the
file you printed (e.g., saves into foo.ps
when you print
foo.c
).
As an example, if you need to print a PostScript file, just hit:
gargantua ~ $ a2ps article.ps -d [article.ps (ps, delegated to PsNup): 7 pages on 4 sheets] [Total: 8 pages on 4 sheets] sent to the default printer
While honoring your defaults settings, a2ps delegates the task to put
two virtual pages per physical page to psnup
, a powerful filter
part of the famous psutils
by Angus Duggan.
Suppose now that you want to display a Texinfo file. Then, provided you have all the programs a2ps needs, just hit
gargantua ~ $ a2ps a2ps.texi -P display [a2ps.texi (texinfo, delegated to texi2dvi): 75 pages on 38 sheets] [Total: 76 pages on 38 sheets] sent to the printer `display'
Once the read documentation, you know you want to print just pages 10 to 20, plus the cover. Just hit:
gargantua ~ $ a2ps a2ps.texi --pages=1,10-20 -d [a2ps.texi (texinfo, delegated to texi2dvi): 13 pages on 7 sheets] [Total: 14 pages on 7 sheets] sent to the default printer
A final word: compressed files can be treated in the very same way:
gargantua ~ $ a2ps a2ps.texi.gz -a1,10-20 -d [a2ps.texi (compressed, delegated to Gzip-a2ps): 13 pages on 7 sheets] [Total: 14 pages on 7 sheets] sent to the default printer
You should be aware that:
-Z
enables the delegations if they are not (see
--list=defaults
for your settings);
a2ps --list=delegations
.
If you still want to save more paper, and you are amongst the set of
happy users of Duplex printers, a2ps will also be able to help you
(See Glossary, for definitions). The option to specify Duplex
printing is --sides=mode
(see PostScript Options).
Here is how to print the documentation in Duplex and send it to the
Duplex printer margot
:
quasimodo ~ a2ps/doc $ a2ps -s2 -Pmargot a2ps.texi [a2ps.texi (texinfo, delegated to texi2dvi): 109 pages on 28 sheets] [Total: 110 pages on 28 sheets] sent to the printer `margot'This is also valid for several files.
Actually, you can do something even more tricky: print a small book!
This is much more complicated than printing Duplex, because the pages
needs to be completely reorganized another way. This is precisely the
job of psbook
, yet another PsUtil from Angus Duggan. But there
is a user option which encapsulates the magic sequence of options:
book
. Therefore, just run
quasimodo a2ps/doc $ a2ps -=book -Pmargot a2ps.texi [a2ps.texi (texinfo, delegated to texi2dvi): 109 pages on 109 sheets] [Total: 109 pages on 109 sheets] sent to the printer `margot'
and voila` !, a booklet printed on margot!
We strongly discourage you to try with several files at once, because the tools then easily get lost. And, after all, the result will be exactly the same once you collated all the booklets together.
Another limitation is that this does not work if it is not sent to a printer. This kind of weird limitations will be solved in the future.
If a2ps did not have the behavior expected, this may be because of the default settings given by your system administrator. Checking those default values is easy:
~ % a2ps --list=defaults Configuration status of a2ps 4.12a ================================== Sheets: ------- medium = A4, portrait page layout = 1 x 1, rows first borders = yes file alignment = page interior margin = 0 More stuff deleted here Internals: ---------- verbosity level = 2 file command = /usr/bin/file -L temporary directory = /tmp library path = /home/akim/.a2ps /usr/share/a2ps/sheets /usr/share/a2ps/ps /usr/share/a2ps/encoding /usr/share/a2ps/afm /usr/share/ogonkify/afm /usr/share/a2ps/ppd /usr/share/a2ps/fonts /usr/share/ogonkify/fonts /usr/share/a2ps
Remember that the on-line help is always available. Moreover, if your
screen is small, you may pipe it into more
. Just trust
this:
a2ps --help | more
Many things are parameterizable in a2ps, but two things are just essential to make sure everything goes right:
--medium
).
--encoding
).
Both values may be checked with a2ps --list=defaults
.
To enable these features, properly set your environment variable
LANG
(see the documentation of your system, for instance
man locale
, man environ
etc.).
The problem with this approach is that a lot more than just messages and
time information is affected: especially the way numbers are written
changes, what may cause problems with awk
and such.
So if you just want messages and time format to be localized, then define:
set LC_MESSAGES=fr ; export LC_MESSAGES set LC_TIME=fr ; export LC_TIME
Here are some tips on how to use a2ps with other programs.
When you print from a mailer (or a news reader), your mailer calls a tool,
say a2ps on a part of the whole mailbox. This makes it difficult for
a2ps to guess that the file is of the type mail
. Therefore, for
better results, make sure to tell a2ps the files are mails. The user
option mail
(or longmail
for longer inputs) encapsulates most
typical tuning users want to print mails (for instance, don't print all the
headers).
Most specifically, if your mailer is:
elm
a2ps -=mail
%s -d
. The option -d
means to print on the default printer.
pine
.pinerc
(of course you can put it in pine.conf
as well):
# Your printer selection printer=a2ps -=mail -d # Special print command personal-print-command=a2ps -=mail -d
This is actually valid for any program that generates PostScript that you want to post-process with a2ps. Use the following command:
a2ps
Not too hard, isn't it?
Nevertheless, this setting suppose your world is OK, your file(1)
detects correctly PostScript files, and your a2ps is configured to
delegate. In case one one these conditions is not met, use:
a2ps -ZEps
Do not forget to tell Netscape whether your printer supports colors, and the type of paper it uses.
Calling a2ps is fairly simple:
a2ps Options... Files...
If no Files... are given, a2ps prints its standard input. If
-
appears in the Files..., it designates the standard input
too.
To read the options and arguments that you give, a2ps uses GNU
getopt
, hence:
a2ps -4m
main.c
and a2ps main.c -4m
are identical.
a2ps -1
-l132
is not the same as a2ps -l132 -1
(the latter being
equivalent to a2ps -1
).
a2ps -4mg main.c -P printer
--pro
will be understood as --prologue
,
--
ends the options. Anything behind --
is considered to
be a file: a2ps -- -2
prints the file -2
1.
Here after a boolean is considered as true (i.e. setting the
option on), if boolean is yes
, or 1
; as false if it
equals no
or 0
; and raise an error otherwise. The
corresponding short option takes no arguments, but corresponds to a
positive answer.
When an argument is presented between square brackets, it means that it is optional. Optional arguments to short option must never be separated from the option.
Task options specify the task a2ps will perform. It will not print, it executes the task and exits successfully.
--version | Option |
print version and exit successfully. |
--help | Option |
Print a short help, and exit successfully. |
--copyright | Option |
Display Copyright and copying conditions, and exit successfully. |
--guess | Option |
Act like file does: display the (key of the) type of the
Files.
For instance, on a This can be very useful on broken systems to understand why a file is printed with a bad style sheet (see Style Sheet Files). |
--which | Option |
Look in the library for the files which names are given as arguments.
For instance:
~ % a2ps --which bw.pro gray.pro /usr/local/share/a2ps/ps/bw.pro /usr/local/share/a2ps/ps/gray.pro If there are several library files matching the name, only the first one is reported: this allows to check which occurrence of a file is used by a2ps. |
--glob | Option |
Look in the library for the files which names match the patterns given
as arguments. For instance:
~ % a2ps --glob 'g*.pro' /usr/local/share/a2ps/ps/gray.pro /usr/local/share/a2ps/ps/gray2.pro |
--list=topic | Option |
Display a report on a2ps' status with respect to topic, and
exit successfully.
topic can be any non-ambiguous abbreviation of:
There are also options meant for the maintainers only, presented for sake of completeness.
|
These options are related to the interface between you and a2ps.
-q | Option |
--quiet | Option |
-@b{-}silent | Option |
be really quiet |
-v[level] | Option |
--verbose[=level] | Option |
tell what we are doing. At
, or
+ . The tokens may be:
When a2ps is launched it consults the environment variable
|
-=shortcut | Option |
--user-option=shortcut | Option |
use the shortcut defined by the user. See Your Shortcuts.
Shortcuts may be freely mixed with regular options and arguments.
There are a few predefined user-options:
|
--debug | Option |
enable debugging features. They are:
|
-D key[=value] | Option |
--define=key[=value] | Option |
Without value, unset the variable key. Otherwise, set it to
value. See Your Variables, for more details. Note that
-Dfoo= gives foo an empty value, though -Dfoo unsets
foo.
|
This options specify the general layout, how the sheet should be used.
-M medium | Option |
--medium=medium | Option |
use output medium medium. See the output of a2ps
--list=media for the list of supported media. Typical values are
A3 , A4 , A5 , B4 , B5 , Letter ,
Legal .
The special medium |
-r | Option |
--landscape | Option |
print in landscape mode |
-R | Option |
--portrait | Option |
print in portrait mode |
--columns=num | Option |
specify the number of columns of virtual pages per physical page. |
--rows=num | Option |
specify the number of rows of virtual pages per physical page. |
--major=direction | Option |
specify whether the virtual pages should be first filled in rows
(direction = rows ) or in columns (direction =
columns ).
|
-1 | Option |
1 x 1 portrait, 80 chars/line, major rows (i.e. alias for --columns=1 --rows=1 --portrait --chars-per-line=80 --major=rows ).
|
-2 | Option |
2 x 1 landscape, 80 chars/line, major rows. |
-3 | Option |
3 x 1 landscape, 80 chars/line, major rows. |
-4 | Option |
2 x 2 portrait, 80 chars/line, major rows. |
-5 | Option |
5 x 1 landscape, 80 chars/line, major rows. |
-6 | Option |
3 x 2 landscape, 80 chars/line, major rows. |
-7 | Option |
7 x 1 landscape, 80 chars/line, major rows. |
-8 | Option |
4 x 2 landscape, 80 chars/line, major rows. |
-9 | Option |
3 x 3 portrait, 80 chars/line, major rows. |
-j | Option |
--borders=boolean | Option |
print borders around virtual pages. |
-A mode | Option |
--file-align=mode | Option |
Align separate files according to mode. This option allows the
printing of more than one file on the same page. mode can be any
one of:
|
--margin[=num] | Option |
Specify the size of the margin (num PostScript points, or 12 points without arguments) to leave in the inside (i.e. left for the front side page, and right for the back side). This is intended to ease the binding. |
This options are related to the content of the virtual pages.
Please note that the options -f
, -L
, -l
, -m
,
and -1
.. -9
all have an influence on the font size. Only
the last one will win (i.e., a2ps -L66 -l80
is the same as
a2ps -l80
).
--line-numbers[=number] | Option |
print the line numbers from number lines to number lines.
Default is 1 .
|
-C | Option |
Alias for --line-numbers=5 .
|
-f size[unit] | Option |
--font-size=size[unit] | Option |
scale font to size for body text. size is a float number,
and unit can be cm for centimeters, points for
PostScript points, and in for inches. Default unit in
points .
To change the fonts used, change the current prologue (see Designing PostScript Prologues. |
-l num | Option |
--chars-per-line=num | Option |
Set the font size so that num columns appear per virtual pages. num is the real number of columns devoted to the body of the text, i.e., no matter whether lines are numbered or not. |
-L num | Option |
--lines-per-page=num | Option |
Set the font size so that num lines appear per virtual pages. This is useful for printing preformatted documents which have a fixed number of lines per page. The minimum number of lines per page is set at 40 and maximum is at 160. If a number less than 40 is supplied, scaling will be turned off. |
-m | Option |
--catman | Option |
Understand UNIX manual output ie: 66 lines per page and
possible bolding and underlining sequences. The understanding of
bolding and underlining is there by default even if --catman is
not specified. You may want to use the ul prologue (See Input Options, option --prologue ) if you prefer underlining over
italics.
If your file is actually a UNIX manual input, i.e., a roff file, then depending whether you left a2ps delegate or not, you will get a readable version of the text described, or a pretty-printed version of the describing file (see Your Delegations). |
-T num | Option |
--tabsize=num | Option |
set tabulator size to num. This option is ignored if
--interpret=no is given.
|
--non-printable-format=format | Option |
specify how non-printable chars are printed. format can be
|
These are the options through which you may define the information you want to see all around the pages.
All these options support text as an argument, which is composed of plain strings and escapes. See Escapes, for details.
-B | Option |
--no-header | Option |
no page headers at all. |
-b[text] | Option |
--header[=text] | Option |
set the page header |
--center-title[=text] | Option |
--left-title[=text] | Option |
--right-title[=text] | Option |
Set virtual page center, left and right titles to text. |
-u[text] | Option |
--underlay[=text] | Option |
use text as under lay (or water mark), i.e., in a light gray, and under every page. |
--left-footer[=text] | Option |
--footer[=text] | Option |
--right-footer[=text] | Option |
Set sheet footers to text. |
-a[Page range] | Option |
--pages[=Page range] | Option |
With no argument, print all the page, otherwise select the pages to
print. Page range is a list of interval, such as -a1 :
print only the first page, -a-3,4,6,10- : print the first 3 pages,
page 4 and 6, and all the page after 10 (included). Giving toc
prints the table of content whatever its page number is.
The pages referred to are the input pages, not the output pages,
that is, in Note that page selection does work with the delegations (see Your Delegations). |
-c | Option |
--truncate-lines=boolean | Option |
Cut lines too large to be printed inside the borders. The maximum line size depends on format and font size used and whether line numbering is enabled. |
-i | Option |
--interpret=boolean | Option |
interpret tab and ff chars. This means that ^L jumps to a new
(virtual) pages, tab advances to the next tabulation.
|
--end-of-line=type | Option |
Specify what sequence of characters denotes the end of line. type
can be:
|
-X key | Option |
--encoding=key | Option |
Use the input encoding identified by key. See Some Encodings,
and the result of
a2ps --list=encodings to know what encodings are supported.
Typical values are ASCII , latin1 ... latin6 ,
ison etc.
|
--stdin=filename | Option |
Give the name filename to the files read through the standard input. |
-t name | Option |
--title=name | Option |
Give the name name to the document. Escapes can be used
(see Escapes).
This is used for instance in the name given to the document from within
the PostScript code (so that It is not the name of the output. It is just a logical title. |
--prologue=prologue | Option |
Use prologue as the PostScript prologue for a2ps.
prologue must be in a file named prologue.pro , which
must be in a directory of your library path (see Library Files).
Available prologues are:
|
--print-anyway=boolean | Option |
force binary printing. By default, the whole print job is stopped as
soon as a binary file is detected. To detect such a file we make use of
a very simple heuristic: if the first sheet of the file contains more
than 40% of non-printing characters, it's a binary file. a2ps also asks
file(1) what it thinks of the type of the file. If file(1)
answers data , the file will also be considered as binary, hence
not printed.
|
-Z | Option |
--delegate=boolean | Option |
Enable delegation of some files to delegated applications. If
delegating is on, then a2ps will not process the file by itself,
but will call an application which handles the file in another way. If
delegation is off, then a2ps will process every file itself.
Typically most people don't want to pretty-print a PostScript source file, but want to print what describes that file. Then set the delegations on. See Your Delegations for information on delegating, and option
|
--toc[=format] | Option |
Generate a Table of Contents, which format is an escape
(see Escapes) processed as a PreScript file (see PreScript). If
no format is given (i.e., you wrote --toc ), use the default
table of contents shape (#{toc} ). If the given format is empty
(i.e., you wrote --toc= ), don't issue the table of contents.
Note that it is most useful to define a variable (see Your Variables), for instance, in a configuration file: Variable: toc.mine \ \\Keyword{Table of Content}\n\ #-1!f\ |$2# \\keyword{$-.20n} sheets $3s< to $3s> ($2s#) \ pages $3p<-$3p> $4l# lines\n||\ \\Keyword{End of toc}\n and to give that variable as argument to Note too that you can generate only the table of content using
a2ps *.c --toc -atoc |
These options are related to the pretty printing features of a2ps.
--highlight-level=level | Option |
Specify the level of highlighting. level can be
--list=style-sheets )
for a description of heavy highlighting.
|
-g | Option |
Alias for --highlight-level=heavy .
|
-E [language] | Option |
--pretty-print[=language] | Option |
With no arguments, set automatic style selection on. Otherwise, set
style to language. Note that setting language to
plain turns off pretty-printing. See Known Style Sheets, and the
output of --list=style-sheets for the available style sheets.
If language is |
--strip-level=num | Option |
Depending on the value of num:
This option is valuable for instance in Note that the current implementation is not satisfactory: some undesired blank lines remain. This is planed to be fixed. |
These are the options to specify what you want to do out of what a2ps
produces. Only a single destination is possible at a time, i.e., if
ever there are several options -o
, -P
or -d
, the
last one is honored.
-o file | Option |
--output=file | Option |
leave output to file file. If file is - , leave
output to the standard output.
|
--version-control=type | Option |
to avoid loosing a file, a2ps offers backup services. This is enabled
when the output file already exists, is regular (that is, no backup is
done on special files such as /dev/null ), and is writable (in
this case, disabling version control makes a2ps fail the very same way
as if version control was disabled: permission denied).
The type of backups made can be set with the
|
--suffix=suffix | Option |
The suffix used for making simple backup files can be set with the
SIMPLE_BACKUP_SUFFIX environment variable, which can be
overridden by this option. If neither of those is given, the default is
~ , as it is in Emacs .
|
-P name | Option |
--printer=name | Option |
send output to printer name. See item Printer: and
Unknown printer: in Your Printers and results of option
--list=defaults to see the bindings between printer names and
commands.
It is possible to pass additional options to |
-d | Option |
send output to the default printer. See item DefaultPrinter: in
Your Printers.
|
The following options are related only to variations you want to produce onto a PostScript output.
--ppd[=key] | Option |
With no argument, set automatic PPD selection, otherwise set the PPD to key. FIXME: what to read. |
-n num | Option |
--copies=num | Option |
print num copies of each page |
-s duplex-mode | Option |
--sides=duplex-mode | Option |
Specify the number of sheet sides, or, more generally, the Duplex mode
(see Glossary). The valid values for duplex-mode are:
|
-S key[:value] | Option |
--setpagedevice=key[:value] | Option |
Pass a page device definition to the generated PostScript output. If no
value is given, key is removed from the definitions.
Note that several --setpagedevice can be accumulated.
For example, command ubu $ a2ps -SDuplex:true -STumble:true NEWS [NEWS (plain): 15 pages on 8 sheets] [Total: 15 pages on 8 sheets] sent to the default printer prints file a2ps -SDuplex:true -STumble:true a2ps.texi Page device operators are implementation dependent but they are standardized. See Page Device Options, for details. |
--statusdict=key[:value] | Option |
--statusdict=key[::value] | Option |
Pass a statusdict definition to the generated PostScript output.
statusdict operators and variables are implementation dependent;
see the documentation of your printer for details. See Statusdict Options, for details. Several --statusdict can be accumulated.
If no value is given, key is removed from the definitions. With a single colon, pass a call to an operator, for instance: a2ps --statusdict=setpapertray:1 quicksort.c prints file With two colons, define variable key to equal value. For instance: a2ps --statusdict=papertray::1 quicksort.c produces /papertray 1 def in the PostScript. |
-k | Option |
--page-prefeed | Option |
enable page prefeeding. It consists in positioning the sheet in the printing area while the PostScript is interpreted (instead of waiting the end of the interpretation of the page before pushing the sheet). It can lead to an significant speed up of the printing. a2ps quotes the access to that feature, so that non supporting printers won't fail. |
-K | Option |
--no-page-prefeed | Option |
disable page prefeeding. |
The escapes are some sequences of characters that will be replaced by their values. They are very much like variables.
They are used in several places in a2ps:
$l.
, $l^
).
All format directives can also be given in format
escape width directive
where
%
#
$
\
\n
, \f
etc.).
+paddinginteger
$+.10n
with a file name $n
=foo.c
gives
.....foo.c
.
If no padding is given,
(white space) is used.
-paddinginteger
$+.10n
gives foo.c.....
.
integer
+integer
. For example, escape
$5P
will expand to something like 12
.
Supported escapes are:
\\
\
\%
%
\$
$
\#
#
#?cond|if_true|if_false|
|
) may be any character. if_true and
if_false may be defined exactly the same way as regular headers,
included escapes and the #?
construct.
The available tests are:
#?1
#?2
#?3
$t1
for
explanation.
#?d
-s2
).
#?j
-j
).
#?l
#?o
#v
is 1).
#?p
#p
is not empty).
#?q
#?r
--major=rows
).
#?v
#?V
tools
flag (See Global Options. option --verbosity
).
#!key|in|between|
|
) may
be any character. in and between are escapes.
The enumerations may be:
#!$
#!f
#!F
#!s
For instance, the escapes The files printed were: #!f|$n|,
|.
evaluated with input a2ps NEWS main.c -o foo.ps
, gives
The files printed were: NEWS, main.c.
.
As an exception, #!
escapes use the width as the
maximum number of objects to enumerate if it is positive, e.g.,
#10!f|$n|, |
lists only the ten first file names. If width
is negative, then it does not enumerate the -width last objects
(e.g., #-1!f|$n|, |
lists all the files but the last).
${var}
${var:-word}
${var:+word}
$[num]
#{key}
#{key:-word}
#{key:+word}
#.
ps
).
%*
hh:mm:ss
$*
hh:mm:ss
$#
%#
%a
Printed by User Name
.
User Name is obtained from the variable user.name
(see Predefined Variables).
%A
Printed by User Name from
Host Name
. The variables user.name
and user.host
are used (see Predefined Variables).
%c
%C
hh:mm:ss
format
$C
hh:mm:ss
format
%d
$d
.
if the directory part is
empty).
%D
yy-mm-dd
format
$D
yy-mm-dd
format
%D{string}
strftime(3)
function.
$D{string}
strftime(3)
function.
%e
Jul 4, 76
in
English, or 14 Juil 89
in French).
$e
%E
July 4, 76
in
English, or Samedi 14 Juillet 89
in French).
$E
$f
\f
\f
(form feed
).
#f0
#f9
%F
dd.mm.yyyy
format.
$F
dd.mm.yyyy
format.
#h
$l^
$l.
--right-title="$q:$l^-$l."
.
$l#
%m
.
character
%M
\n
\n
(new line
).
%n
user.login
(see Predefined Variables).
$n
%N
user.name
(see Predefined Variables).
$N
foo.c
, it will produce foo
).
#o
-P
,
or of -o
).
#O
file
is defined as > $n.%.
, then #O
returns
foo.c.ps
when printing foo.c
to PostScript. #o
would have returned file
.
#p
--pages=1-10,15
, and the current page is 8, then #p
evaluates to 1-3,8
.
$p^
$p.
, evaluated at the end of sheet, is also the number
of the last page of this file appearing on this sheet.
$p-
$p^-$p.
, if $p^
and $p.
are different, otherwise it is equal to $p.
.
%p.
$p.
%p#
$p#
$p<
$p>
%q
Page %p.
$q
Page $p.
%Q
Page %p./%p#
$Q
Page $p./$p#
$s<
%s.
$s.
$s>
%s#
$s#
%t
$t
$t1
$t2
$t3
mail-folder
style, tag 1 is the title of the mail, and tag 2 its author.
%T
hh:mm
$T
hh:mm
#v
%V
#w
%W
mm/dd/yy
format
$W
mm/dd/yy
format
/usr/local/etc/a2ps.cfg
)
unless you have defined the environment variable A2PS_CONFIG
, in
which case a2ps reads the file it points to;
$HOME/.a2ps/a2psrc
)
./.a2psrc
)
Because a2ps needs architecture dependent information (such as the
local lpr
command) and architecture independent information (such
as the type of your printers), users have found useful that
a2ps.cfg
be dedicated to architecture dependent information. A
sub configuration file, a2ps-site.cfg
(see Including Configuration Files) is included from a2ps.cfg
.
The file a2ps.cfg
is updated when you update a2ps, while
a2ps-site.cfg
is not, to preserve local definitions.
In the configuration files, empty lines and lines starting with #
are comments.
The other lines have all the following form:
Topic: Arguments
where Topic: is a keyword related to what you are customizing, and
Arguments the customization. Arguments may be spread on
several lines, provided that the last character of a line to continue is
a \
.
In the following sections, each Topic: is detailed.
Ghostview
Include: file | Configuration Setting |
Include (read) the configuration file. if file is a
relative path (i.e., it does not start with / ), then it is
relatively to the current configuration file.
|
This is especially useful for the site specific configuration file
etc/a2ps.cfg
: you may tune your printers etc. in a separate file
for easy upgrade of a2ps (and hence of its configuration files).
To define the default library path, you can use:
LibraryPath: path | Configuration Setting |
Set the library path the path. |
AppendLibraryPath: path | Configuration Setting |
Add path at the end of the current library path. |
PrependLibraryPath: path | Configuration Setting |
Add path at the beginning of the current library path. |
Note that for users configuration files, it is better not to set the
library path, because the system's configuration has certainly been
built to cope with your system's peculiarities. Use
AppendLibraryPath:
and PrependLibraryPath:
.
Options: options+ | Configuration Setting |
Give a2ps a list of command line options. options+ is any
sequence of regular command line options (see Invoking a2ps).
It is the correct way to define the default behavior you expect from
a2ps. If for instance you want to use Options: --medium=Letter It is exactly the same as always giving a2ps the option
|
The quoting mechanism is the same as that of a shell. For instance
Options: --right-title="Page $p" --center-title="Hello World!" Options: --title="arg 'Jack said \\\"hi\\\"' has double quotes"
Medium: name dimensions | Configuration Setting |
Define the medium name to have the dimensions (in PostScript
points, i.e., 1/72 of inch).
There are two formats supported:
|
A general scheme is used, so that whatever the way you should address the printers on your system, the interface is still the same. Actually, the interface is so flexible, that you should understand `named destination' when we write `printer'.
Printer: name PPD-key destination | Configuration Setting |
Printer: name destination | Configuration Setting |
Printer: name PPD-key | Configuration Setting |
Specify the destination of the output when the option -P
name is given. If PPD-key is given, declare the printer
name to be described by the PPD file PPD-key.ppd . If
destination is not given, used that of the UnknownPrinter: .
The destination must be of one of the following forms:
|
UnknownPrinter: [PPD-key] destination | Configuration Setting |
Specify the destination of the output when when the option -P name
is given, but there is no Printer: entry for name.
|
DefaultPrinter: [PPD-key] destination | Configuration Setting |
Specify the destination of the output when when the option -d
(send to default output) is given.
|
Escapes expansion is performed on destination (see Escapes).
Recall that #o
is evaluated to the destination
name, i.e., the argument given to -P
.
For instance
# My Default Printer is called dominique DefaultPrinter: | lp -d dominique # `a2ps foo.c -P bar' will pipe into `lp -d bar' UnknownPrinter: | lp -d #o # `a2ps -P foo' saves into the file `foo' Printer: foo > foo.ps Printer: wc | wc Printer: lw | lp -d printer-with-a-rather-big-name # E.g. `a2ps foo.c bar.h -P file' will save into `foo.c.ps' Printer: file > $n.#. # E.g. `a2ps foo.c bar.h -P home' will save into `foo.ps' # in user's home Printer: home > ${HOME}/$N.#. # Here we address a printer which is not PostScript Printer: deskj | gs -q -sDEVICE=ljet3d -sOutputFile=- - \ | lpr -P laserwriter -h -l
MS-DOS users, and non-PostScript printer owners should take advantage in getting good configuration of these entries.
You can define some kind of `Macro Options' which stand for a set of options.
UserOption: shortcut options... | Configuration Setting |
Define the shortcut to be the list of options.... When a2ps
is called with -=shortcut (or
--user-option=shortcut ), consider the list of
options....
|
Examples are
# This emulates a line printer: no features at all # call a2ps -=lp to use it UserOption: lp -1m --pretty-print=plain -B --borders=no # When printing mail, I want to use the right style sheet with strong # highlight level, and stripping `useless' headers. UserOption: mail -Email -g --strip=1
Thou shalt start your PostScript DSC conformant files with%!PS-Adobe-3.0
The bad news is that some printers will reject this header. Then you may change this header without any worry since the PostScript produced by a2ps is also 100% PostScript level 12.
OutputFirstLine: magic-number | Configuration Setting |
Specify the header of the produced PostScript file to be magic-number.
Typical values include %!PS-Adobe-2.0 , or just %! .
|
In the PostScript file is dropped information on where sheets begin and
end, so that post processing tools know where is the physical page 1, 2 etc.
With this information can be also stored a label, i.e., a human readable text
(typically the logical page numbers), which
is for instance what Ghostview
shows as the list of page numbers.
a2ps lets you define what you want in this field.
PageLabelFormat: format | Configuration Setting |
Specify the format to use to label the PostScript pages.
format can use Escapes (see Escapes). Two
variables are predefined for this: #{pl.short} and
#{pl.long} .
|
There are many places in a2ps where one would like to have uniform way of extending things. It once became clear that variables where needed in a2ps.
Variable: key value | Configuration Setting |
Define the escape #{key} to be a short cut for
value. key must not have any character from :(){} .
|
As as example, here is a variable for psnup
, which encloses all
the option passing one would like. Delegations are then easier to
write:
Variable: psnup psnup -#v -q #?j|-d|| #?r||-c| -w#w -h#h
It is strongly suggested to follow a .
(dot) separated hierarchy,
starting with:
del
pro
pro.matrix.gray
).
ps
ps.page_label
), the header etc.
pl
--page-label
in Input Options.
toc
--toc
in Input Options.
user
This naming convention has not fully stabilized. We apologize for the inconvenience this might cause to users.
There are a few predefined variables. The fact that a2ps builds them
at startup changes nothing to their status: they can be modified like
any other variable using --define
(see Global Options).
In what follows, there are numbers (i) like this, or (ii) this. It
means that a2ps first tries the solution (i), if a result is obtained
(non empty value), this is the value given to the variable. Otherwise
it tries solution (ii), etc. The rationale behind the order is usually
from user modifiable values (e.g. environment variables) through
system's hard coded values (e.g., calls to getpwuid
) and finally
arbitrary values.
user.comments
pw_gecos
after the first ,
), (ii) not defined.
user.home
HOME
, (ii) the system's database (using getpwuid
), (iii)
the empty string.
user.host
gethostname
or uname
), (ii) the empty string.
user.login
bgates
). Computed by (i) the environment
variable LOGNAME
, (ii) the environment variable USERNAME
,
(iii) the system's database (using getpwuid
), (iv) the translated
string user
.
user.name
William Gates
). Computed by (i) the
system's database (pw_gecos
up to the first ,
), (ii)
capitalized value of the variable user.login
unless it was the
translated string user
, (iii) the translated string Unknown
User
.
There are some files you don't really want a2ps to pretty-print,
typically page description files (e.g., PostScript files, roff
files,
etc.). You can let a2ps delegate the treatment of these files to other
applications. The behavior at run time depends upon the option
--delegate
(see Input Options).
Delegation: name in:out command | Configuration Setting |
Define the delegation name. It is to be applied upon files of
type in when output type is out3 thanks to
command. Both in and out are a2ps type keys such as
defined in sheets.map (see The Entry in sheets.map).
|
command should produce the file on its standard output. Of course
escapes substitution is performed on command (see Escapes).
In particular, command should use the input file
$f
.
# In general, people don't want to pretty-print PostScript files. # Pass the PostScript files to psnup Delegation: PsNup ps:ps \ psselect #?V||-q| -p#?p|#p|-| $f | \ psnup -#v -q #?j|-d|| #?r||-c| -w#w -h#h
Advantage should be taken from the variables, to encapsulate the peculiarities of the various programs.
# Passes the options to psnup. # The files (in and out) are to be given Variable: psnup psnup -#v #?V||-q| #?j|-d|| #?r||-c| -w#w -h#h # Passes to psselect for PS page selection Variable: psselect psselect #?V||-q| -p#?p|#p|-| # In general, people don't want to pretty-print PostScript files. # Pass the PostScript files to psnup Delegation: PsNup ps:ps #{psselect} $f | #{psnup}
Temporary file names (#f0
to #f9
) are available for
complex commands.
# Pass DVI files to dvips. # A problem with dvips is that even on failure it dumps its prologue, # hence it looks like a success (output is produced). # To avoid that, we use an auxiliary file and a conditional call to # psnup instead of piping. Delegation: dvips dvi:ps #{dvips} $f -o #f0 && #{psnup} #f0
First of all, select carefully the applications you will use for the delegations. If a filter is known to cause problems, try to avoid it in delegations4. As a thumb rule, you should check that the PostScript generating applications produce files that start by:
%!PS-Adobe-3.0a2ps needs the
%%BeginSetup
-%%EndSetup
section
in order to output correctly the page device definitions. It can happen
that your filters don't output this section. In that case, you should
insert a call to fixps
right after the PostScript generation:
########## ROFF files # Pass the roff files to groff. Ask grog how groff should be called. # Use fixps to ensure there is a %%BeginSetup/%%EndSetup section. Delegation: Groff roff:ps \ eval `grog -Tps '$f'` | fixps #?V!!-q! | #{d.psselect} | #{d.psnup}
There are some services expected from the delegations. The delegations you may write should honor:
$f
. You should be aware that there are
people who have great fun having spaces or dollars in their file names,
so you probably should always use '$f'
. Some other variables are
affected. Yes, I know, we need a special mechanism for '
itself.
Well, we'll see that later ;-)
.
#w
and #h
.
#v
.
1-2,4-6,10-
for instance) is available
by #p
.
#?V
is set (see the above
example with groff
).
If ever you need several commands, do not use ;
to separate them,
since it may prevent detection of failure. Use &&
instead.
The slogan "the sooner, the better" should be applied here: in
the processing chain, it is better to ask a service to the first
application that supports it. An example will make it clear: when
processing a DVI
file, dvips
knows better the page numbers
than psselect
would. So a DVI
to PostScript delegation
should ask the page selection (#p
) to dvips
, instead of
using psselect
later in the chain. An other obvious reason here
is plain efficiency (globally, less data is processed).
The purpose of this section is not to document all the predefined
delegations, for this you should read the comments in the system
configuration file a2ps.cfg
. We just want to explain some choices,
and give hints on how to make the best use of these delegations.
dvips (DVI to PostScript) | Delegation |
There is a problem when you use a naive implementation of this
delegation: landscape jobs are not recognized, and therefore n-upping
generally fails miserably. Therefore, a2ps tries to guess if the file
is landscape by looking for the keyword landscape in it, using
strings(1) :
Delegation: dvips dvi:ps\ if strings $f | sed 3q | fgrep landscape > /dev/null 2>&1; then \ #{d.dvips} -T#hpt,#wpt $f -o #f0 && #?o|cat|#{d.psnup} -r| #f0;\ else \ #{d.dvips} $f -o #f0 && #{d.psnup} #f0; \ fi In order to have that rule work correctly, it is expected from the TeX, or LaTeX file to include something like: \renewcommand{\printlandscape}{\special{landscape}} \printlandscape in the preamble. We don't use a pipe because dvips always outputs data (its prologue) even if it fails, what prevents error detection. |
LaTeX (LaTeX to DVI) | Delegation |
We use a modern version of the shell script texi2dvi , from the
package Texinfo , which runs makeindex , bibtex and
latex as many times as needed. You should be aware that if the
file includes files from other directories, it may miss some
compilation steps. Other cases (most typical) are well handled.
|
There are settings that only meant for a2ps that you can tune by yourself.
FileCommand: command | Configuration Setting |
The command to run to call file(1) on a file. If possible, make
it follow the symbolic links.
|
To be general and to allow as much customization as possible, a2ps avoids to hard code its knowledge (encodings, PostScript routines, etc.), and tries to split it in various files. Hence it needs a path, i.e., a list of directories, in which it may find the files it needs.
The exact value of this library path is available by a2ps
--list=defaults
. Typically its value is:
gargantua ~ $ a2ps --list=defaults Configuration status of a2ps 4.13 More stuff deleted here Internals: verbosity level = 2 file command = /usr/ucb/file -L temporary directory = library path = /inf/soft/infthes/demaille/.a2ps /usr/local/share/a2ps/sheets /usr/local/share/a2ps/ps /usr/local/share/a2ps/encoding /usr/local/share/a2ps/afm /usr/local/share/a2ps/printers /usr/local/share/a2ps
You may change this default path through the configuration files (see Your Library Path).
If you plan to define yourself some files for a2ps, they should be in one of those directories.
In various places a documentation can be given. Since some parts of this document and of web pages are extracted from documentations, some tags are needed to provide a better layout. The format is a mixture made out of Texinfo like commands, but built so that quick and easy processing can be made.
These tags are:
code(
text)code
bold
prologue mentions the bw
prologue:
Documentation This style is meant to replace the old option code(-b)code of a2ps 4.3. It is a copy of the black and white prologue, but in which all the fonts are in Bold. EndDocumentation
href(
link)href(
text)href
@example
@end example
gnuc
style sheet:
documentation is "Declaration of functions are highlighted" "emph(only)emph if you start the function name" "in the first column, and it is followed by an" "opening parenthesis. In other words, if you" "write" "@example" "int main (void)" "@end example" "it won't work. Write:" "@example" "int" "main (void)" "@end example" end documentation
@itemize
@item
text
@end itemize
Many things are defined through files. There is a general scheme to associate an object to the files to use: map files. They are typically used to:
encoding.map
file will
map these three names to the same Encoding Description File.
Courier-BoldOblique.afm
: it is the same as
Courier-Bold.afm
. The fonts.map
file is here to associate
a font file name to a font name.
The syntax of these files is:
#
is a comment.
***
path
requests that the file designated by path be included at this point.
key value
meaning that when looking for key (e.g., name of a font, an encoding etc.), a2ps should use value (e.g., font file name, encoding description file name etc.).
The map files used in a2ps are:
encoding.map
fonts.map
sheets.map
Even when a PostScript printer knows the fonts you want to use, using these fonts requires some description files.
See Map Files, for a description of the map files. This file associates the font-key to a font name. For instance:
Courier pcrr Courier-Bold pcrb Courier-BoldOblique pcrbo Courier-Oblique pcrro
associates to font named Courier
, the key pcrr
. To be
recognized, the font name must be exact: courier
and
COURIER
are not admitted.
There are two kinds of data a2ps needs to use a font:
font-key.afm
), which describes the metrics
information corresponding to font;
make_fonts_map.sh
.
First, you need to find the directories which store the fonts you want to use, and extend the library path so that a2ps sees those directories. For instance, add:
AppendLibraryPath: /usr/local/share/ghostscript/fonts
Then run make_fonts_map.sh
. It should be located in the
afm/
directory of the system's a2ps hierarchy. Typically
/usr/local/share/a2ps/afm/make_fonts_map.sh
.
This script asks a2ps for the library path, wanders in this path
collecting AFM
files, and digging information in them.
Once the script has finished, a file fonts.map.new
was created.
Check its integrity, and if it's correct, either replace the old
fonts.map
with it, or rename fonts.map.new
as
fonts.map
and place it higher in the the library path (for
instance in your ~/.a2ps/
directory).
The style sheets are defined in various files. See see Pretty Printing for the structure of these files. As for most other features,
there is main file, a road map, which defines in which condition a style
sheet should be used (see Map Files). This file is
sheets.map
.
Its format is simple:
style-key: patterns
or
include(file)
The patterns need not be on separate lines. There are two kinds of patterns:
style-key.ssh
).
file(1)
matches pattern, then
select style style-key.
Currently flags can only be i
, standing for an insentive
match. Please note that the matching is not truly case insensitive:
rather, a lower case version of the string is compared to the pattern
as is, i.e., the pattern should itself be lower case.
The special style-key binary
tells a2ps to consider that
the file should not be printed, and will be ignored, unless option
--print-anyway
is given.
If a style name can't be found, the plain style is used.
The map file is read bottom up, so that the "last" match is honored.
Two things are to retain from this:
stdin
, then a2ps will run
file(1)
. However, unless you specify a fake file name with
--stdin
, pattern matching upon the name is turn off. In general
you can expect correct delegations, but almost never pretty printing.
file
is wrong on some files, a2ps may use bad style sheets.
In this case, do try option --guess
, compare it with the output
of file
, and if the culprit is file
, go and complain to
your system administrator :-), or fix it by defining your own filename
pattern matching rules.
Consider the case of Texinfo files as an example (the language in which
this documentation is written). Files are usually named
foo.texi
, bar.txi
, or even baz.texinfo
.
file(1)
is able to recognize Texinfo files:
doc % file a2ps.texi a2ps.texi: Texinfo source text
Therefore the sheets.map would look like:
# Texinfo files texinfo: /*.txi/ /*.texi/ /*.texinfo/ <Texinfo source*>
This section is actually taken from the web pages of Alis Technologies inc.
Document encoding is the most important but also the most sensitive and explosive topic in Internet internationalization. It is an essential factor since most of the information distributed over the Internet is in text format. But the history of the Internet is such that the predominant - and in some cases the only possible - encoding is the very limited ASCII, which can represent only a handful of languages, only three of which are used to any great extent: English, Indonesian and Swahili.
All the other languages, spoken by more than 90% of the world's population, must fall back on other character sets. And there is a plethora of them, created over the years to satisfy writing constraints and constantly changing technological limitations. The ISO international character set registry contains only a small fraction; IBM's character registry is over three centimeters thick; Microsoft and Apple each have a bunch of their own, as do other software manufacturers and editors.
The problem is not that there are too few but rather too many choices, at least whenever Internet standards allow them. And the surplus is a real problem; if every Arabic user made his own choice among the three dozen or so codes available for this language, there is little likelihood that his "neighbor" would do the same and that they would thus be able to understand each other. This example is rather extreme, but it does illustrate the importance of standards in the area of internationalization. For a group of users sharing the same language to be able to communicate,
Certain character sets stand out either because of their status as an official national or international standard, or simply because of their widespread use.
First off, there is the ISO 8859 standards series that standardize a dozen character sets that are useful for a large number of languages using the Latin, Cyrillic, Arabic, Greek and Hebrew alphabets. These standards have a limited range of application (8 bits per character, a maximum of 190 characters, no combining) but where they suffice (as they do for 10 of the 20 most widely used languages), they should be used on the Internet in preference to other codes. For all other languages, national standards should preferably be chosen or, if none are available, a well-known and widely-used code should be the second choice.
Even when we limit ourselves to the most widely used standards, the overabundance remains considerable, and this significantly complicates life for truly international software developers and users of several languages, especially when such languages can only be represented by a single code. It was to resolve this problem that both Unicode and the ISO 10646 International standard were created. Two standards? Oh no! Their designers soon realized the problem and were able to cooperate to the extent of making the character set repertoires and coding identical.
ISO 10646 (and Unicode) contain over 30,000 characters capable of representing most of the living languages within a single code. All of these characters, except for the Han (Chinese characters also used in Japanese and Korean), have a name. And there is still room to encode the missing languages as soon as enough of the necessary research is done. Unicode can be used to represent several languages, using different alphabets, within the same electronic document.
The support of the encodings in a2ps is completely taken out of the code. That is to say, adding, removing or changing anything in its support for an encoding does not require programming, nor even being a programmer.
See What is an Encoding, if you want to know more about this.
See Map Files, for a description of the map files.
The meaningful lines of the encoding.map
file have the form:
alias key iso-8859-1 latin1 latin1 latin1 l1 latin1
where
--encoding
, but also the encodings dynamically
required, as for instance in the mail
style sheet (support for
MIME).
When encoding is asked, the lower case version of encoding
must be equal to alias.
key.edf
, Encoding Description Files).
The encoding description file describing the encoding key is named
key.edf
. It is subject to the same rules as any other
a2ps file:
#
are ignored.
The entries are
Name:
Name: ISO-8859-1
Documentation/EndDocumentation
Documentation Also known as ISO Latin 1, or Latin 1. It is a superset of ASCII, and covers most West-European languages. EndDocumentation
Substitute:
Courier
, Times-Roman
...) do not support many encodings
(for instance it does not support Latin 2). To avoid that Latin 2 users
have to replace everywhere calls to Courier
, a2ps allows to
specify that whenever a font is called in an encoding, then another font
should be used.
For instance in iso2.edf
one can read:
# Fonts from Ogonkify offer full support of ISO Latin 2 Substitute: Courier Courier-Ogonki Substitute: Courier-Bold Courier-Bold-Ogonki Substitute: Courier-BoldOblique Courier-BoldOblique-Ogonki Substitute: Courier-Oblique Courier-Oblique-Ogonki
Default:
Courier
equivalent is the best choice.
Default: Courier-Ogonki
Vector:
bell
in ASCII
(^G
) should not be named). The special name .notdef
is to
be used when the character is not printable.
Warning. Make sure to use real, official, PostScript names.
Using names such as c123
may be the sign you use unusual names.
On the other hand PostScript names such as afii8879
are common.
Most of the following information is a courtesy of Alis Technologies inc. and of Roman Czyborra's page about The ISO 8859 Alphabet Soup. See What is an Encoding, is an instructive presentation of the encodings.
The known encodings are:
ASCII (ascii.edf )
|
Encoding |
US-ASCII. |
HPRoman (hp.edf )
|
Encoding |
The 8 bits Roman encoding for HP. |
IBM-CP437 (ibm-cp437.edf )
|
Encoding |
This encoding is meant to be used for PC files with drawing lines. |
IBM-CP850 (ibm-cp850.edf )
|
Encoding |
Several characters may be missing, especially Greek letters and some mathematical symbols. |
ISO-8859-1 (iso1.edf )
|
Encoding |
The ISO-8859-1 character set, often simply referred to as Latin 1,
covers most West European languages, such as French, Spanish, Catalan,
Basque, Portuguese, Italian, Albanian, Rhaeto-Romanic, Dutch, German,
Danish, Swedish, Norwegian, Finnish, Faroese, Icelandic, Irish,
Scottish, and English, incidentally also Afrikaans and Swahili, thus
in effect also the entire American continent, Australia and the
southern two-thirds of Africa. The lack of the ligatures Dutch IJ,
French OE and ,,German" quotation marks is considered tolerable.
The lack of the new C=-resembling Euro currency symbol U+20AC has opened the discussion of a new Latin0. |
ISO-8859-2 (iso2.edf )
|
Encoding |
The Latin 2 character set supports the Slavic languages of Central
Europe which use the Latin alphabet. The ISO-8859-2 set is used for
the following languages: Czech, Croat, German, Hungarian, Polish,
Romanian, Slovak and Slovenian.
Support is provided thanks to Ogonkify. |
ISO-8859-3 (iso3.edf )
|
Encoding |
This character set is used for Esperanto, Galician, Maltese and Turkish.
Support is provided thanks to Ogonkify. |
ISO-8859-4 (iso4.edf )
|
Encoding |
Some letters were added to the ISO-8859-4 to support languages such as
Estonian, Latvian and Lithuanian. It is an incomplete precursor of the
Latin 6 set.
Support is provided thanks to Ogonkify. |
ISO-8859-5 (iso5.edf )
|
Encoding |
The ISO-8859-5 set is used for various forms of the Cyrillic
alphabet. It supports Bulgarian, Byelorussian, Macedonian, Serbian and
Ukrainian.
The Cyrillic alphabet was created by St. Cyril in the 9th century from the upper case letters of the Greek alphabet. The more ancient Glagolithic (from the ancient Slav glagol, which means "word"), was created for certain dialects from the lower case Greek letters. These characters are still used by Dalmatian Catholics in their liturgical books. The kings of France were sworn in at Reims using a Gospel in Glagolithic characters attributed to St. Jerome. Note that Russians seem to prefer the KOI8-R character set to the ISO set for computer purposes. KOI8-R is composed using the lower half (the first 128 characters) of the corresponding American ASCII character set. |
ISO-8859-7 (iso7.edf )
|
Encoding |
ISO-8859-7 was formerly known as ELOT-928 or ECMA-118:1986. It is meant for modern Greek. |
ISO-8859-9 (iso9.edf )
|
Encoding |
The ISO 8859-9 set, or Latin 5, replaces the rarely used Icelandic
letters from Latin 1 with Turkish letters.
Support is provided thanks to Ogonkify. |
ISO-8859-10 (iso10.edf )
|
Encoding |
Latin 6 (or ISO-8859-10) adds the last letters from Greenlandic and
Lapp which were missing in Latin 4, and thereby covers all
Scandinavia.
Support is provided thanks to Ogonkify. |
ISO-8859-13 (iso13.edf )
|
Encoding |
Latin7 (ISO-8859-13) is going to cover the Baltic Rim and re-establish
the Latvian (lv) support lost in Latin6 and may introduce the local
quotation marks.
Support is provided thanks to Ogonkify. |
ISO-8859-15 (iso15.edf )
|
Encoding |
The new Latin9 nicknamed Latin0 aims to update Latin1 by replacing
some less needed symbols (some fractions and accents) with forgotten
French and Finnish letters and placing the U+20AC Euro sign in the
cell of the former international currency sign.
Very few fonts yet offer the possibility to print the Euro sign. |
KOI8 (koi8.edf )
|
Encoding |
KOI-8 (+Ëë) is a subset of ISO-IR-111 that can be used in Serbia, Belarus etc. |
MS-CP1250 (ms-cp1250.edf )
|
Encoding |
Microsoft's CP-1250 encoding (aka CeP). |
Macintosh (mac.edf )
|
Encoding |
For the Macintosh encoding. The support is not sufficient, and a lot of characters may be missing at the end of the job (especially Greek letters). |
The main feature of a2ps is its pretty-printing capabilities. Two different levels of pretty printing can be reached:
<=
and >=
will be replaced by
the corresponding single character from the font Symbol.
Note that the difference is up to the author of the style sheet.
IF IF == THEN THEN THEN := ELSE ELSE ELSE := IF
is legal, then a2ps is not the tool you need. Indeed a2ps just looks for some keywords, or some sequences.
68000 (68000.ssh )
|
Style Sheet |
Althought designed at the origin for the 68k's assembler, this style sheet seems to handle rather well other dialects. |
a2ps configuration file (a2psrc.ssh )
|
Style Sheet |
Meant to print files such as a2ps.cfg , or .a2ps/a2psrc , etc.
|
a2ps style sheet (ssh.ssh )
|
Style Sheet |
Second level of highligthing (option -g )) substitutes the LaTeX symbols.
|
Ada (ada.ssh )
|
Style Sheet |
This style sheets cover Ada 95. If you feel the need for Ada 83, you'll have to design another style sheet. |
ASN.1 (asn1.ssh )
|
Style Sheet |
Written by Philippe Coucaud. ASN.1 (Abstract Syntax Notation One) is used to define the protocol data units (PDUs) of all application layer protocols to date. |
Autoconf (autoconf.ssh )
|
Style Sheet |
Suitable for both configure.in and library m4 files.
|
AWK (awk.ssh )
|
Style Sheet |
Written by Edward Arthur. This style is devoted to the AWK pattern scanning and processing language. It is supposed to support classic awk, nawk and gawk. |
B (b.ssh )
|
Style Sheet |
Written by Philippe Coucaud. B is a formal specification method mostly used to describe critical systems. It is based on the mathematical sets theory. |
BC (bc.ssh )
|
Style Sheet |
bc is an arbitrary precision calculator language. |
Bourne Shell (sh.ssh )
|
Style Sheet |
Some classical program names, or builtin, are highlighted in the second level of pretty-printing. |
C (c.ssh )
|
Style Sheet |
This style does not highlight the function definitions. Another style which highlights them, GNUish C, is provided (gnuc.ssh). It works only if you respect some syntactic conventions. |
C Shell (csh.ssh )
|
Style Sheet |
Written by Jim Diamond. Some classical program names, and/or builtins, are highlighted in the second level of pretty-printing. |
C++ (cxx.ssh )
|
Style Sheet |
Should handle all known variations of C++. Most declarations (classes etc.) are not highlighted as they should be. Please, step forward! |
CAML (caml.ssh )
|
Style Sheet |
This style is obsolete: use OCaml instead. |
ChangeLog (chlog.ssh )
|
Style Sheet |
This style covers the usual ChangeLog files. |
Claire (claire.ssh )
|
Style Sheet |
Claire is a high-level functional and object-oriented language with
advanced rule processing capabilities. It is intended to allow the
programmer to express complex algorithms with fewer lines and in an
elegant and readable manner.
To provide a high degree of expressivity, Claire uses:
|
Common Lisp (clisp.ssh )
|
Style Sheet |
Written by Juliusz Chroboczek.
It is not very clear what should be considered as a `keyword' in
Common Lisp. I like binders, control structures and declarations to
be highlighted, but not assignments.
Names of defstructs are not highlighted because this would not work with defstruct options. |
Coq Vernacular (coqv.ssh )
|
Style Sheet |
This style is devoted to the Coq v 5.10 vernacular language. |
CORBA IDL (cidl.ssh )
|
Style Sheet |
Written by Bob Phillips. A first attempt at a style sheet for OMG CORBA IDL. I believe I captured all the keywords for CORBA 2.2 IDL. I also stole code from gnuc.ssh to print the method names in bold face. I'm not sure I quite like my own choices for Keyword_strong and Keyword, so I'm looking for feedback. Note that, as with gnuc.ssh, for a method name to be noted as such, the left parenthesis associated with the argument list for the method must appear on the same line as the method name. |
CPP (cpp.ssh )
|
Style Sheet |
C traditional preprocessor handling, mostly meant to be inherited. |
dc_shell (dc_shell.ssh )
|
Style Sheet |
Written by Philippe Le Van. Synopsys Design Compiler is a synthesis tool used by electronic companies for the design of their chips. This sheet is very incomplete, we have a lot of keywords to add, eventually options to highlight... The Label_strong style is used for commands which change the design. |
Eiffel (eiffel.ssh )
|
Style Sheet |
Eiffel is an object oriented language that also includes a
comprehensive approach to software construction: a method.
The language itself is not just a programming language but also covers analysis, design and implementation. Heavy highlight uses symbols to represent common math operators. |
Emacs Lisp (elisp.ssh )
|
Style Sheet |
Written by Didier Verna. This style sheet includes support for some extensions dumped with XEmacs. |
Encapsulated PostScript (eps.ssh )
|
Style Sheet |
Illegal PostScript operators are highlighted as Errors. |
Extended Tcl (tclx.ssh )
|
Style Sheet |
Written by Phil Hollenback. Extensions to plain Tcl. |
Fortran (fortran.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai.
There are several Fortran dialects, depending whether, on the one
hand, you use Fortran 77 or Fortran 90/95, and, on the other hand,
Fixed form comments, or Free form comments.
The style sheets This style sheet tries to support any of the various flavors (Fortran 77/90/95, fixed or free form). For more specific uses, you should use either:
|
Fortran 77 Fixed (for77-fixed.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai. Dedicated to Fortran 77 in fixed form, i.e., comments are lines starting with c, C, or *, and only those lines are comments. |
Fortran 77 Free (for77-free.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai. Dedicated to Fortran 77 in free form, i.e., comments are introduced by ! anywhere on the line, and nothing else is a comment. |
Fortran 77 Keywords (for77kwds.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai.
This sheet implements only Fortran 77 keywords, and avoids implementing
comments support. This is to allow for implementation of either fixed
or free source form.
See the documentation of the style sheet |
Fortran 90 Fixed (for90-fixed.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai. Dedicated to Fortran 90/95 in fixed form, i.e., comments are lines starting with c, C, or *, and only those lines are comments. |
Fortran 90 Free (for90-free.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai. Dedicated to Fortran 90/95 in free form, i.e., comments are introduced by ! anywhere on the line, and nothing else is a comment. |
Fortran 90 Keywords (for90kwds.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai.
This sheet implements the superset which Fortran 90 and Fortran 95 provide
over Fortran 77.
See the documentation of the style sheet |
Fortran Fixed (for-fixed.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai.
Implements comments of Fortran in fixed form, i.e., comments are
lines starting with c, C, or *, and only those lines are comments.
No other highlighting is done.
See the documentation of the style sheet |
Fortran Free (for-free.ssh )
|
Style Sheet |
Written by Denis Girou, Alexander Mai. Dedicated to Fortran in free form, i.e., comments are introduced by ! anywhere on the line, and nothing else is a comment. |
GNUish C (gnuc.ssh )
|
Style Sheet |
Declaration of functions are highlighted only if you start
the function name in the first column, and it is followed by an
opening parenthesis. In other words, if you write
int main (void)it won't work. Write: int main (void) |
GNUMakefile (gmake.ssh )
|
Style Sheet |
Written by Alexander Mai. Special tokens of GNUmakefiles and non terminal declarations are highlighted. |
Haskell (haskell.ssh )
|
Style Sheet |
Written by Ilya Beylin. Haskell: non-strict functional programming language http::/www.haskell.org/ |
HTML (html.ssh )
|
Style Sheet |
Written by Wesley J. Chun.
This style is meant to pretty print HTML source files, not to simulate
its interpretation (i.e., <bold>foo</bold> does not print foo
in bold). If you really meant to print the result of the HTML file
interpreted, then you should turn the delegations on, and make sure
a2ps has HTML delegations.
|
IDL (idl.ssh )
|
Style Sheet |
Written by Robert S. Mallozzi, Manfred Schwarb. Style sheet for IDL 5.2 (Interactive Data Language). Obsolete routines are not supported. http://www.rsinc.com. |
InstallShield 5 (is5rul.ssh )
|
Style Sheet |
Written by Alex. InstallShield5 _TM_ RUL script. |
Java (java.ssh )
|
Style Sheet |
Written by Steve Alexander. Documentation comments are mapped to strong comments, and any other comment is plain comment. |
JavaScript (js.ssh )
|
Style Sheet |
Written by Scott Pakin. Keywords used are everything listed in the Client-Side JavaScript Reference 1.3, plus "undefined" (why isn't that listed?) and "prototype". I omitted the semi-standard a2ps optional operators for equality, because JavaScript's use of both strict- and non-strict equality might ambiguate the output. Finally, regular expressions are formatted like strings. |
LACE (lace.ssh )
|
Style Sheet |
This is meant for the Eiffel equivalent of the Makefiles. |
Lex (lex.ssh )
|
Style Sheet |
In addition to the C constructs, it highlights the declaration of
states, and some special % commands.
|
Lout (lout.ssh )
|
Style Sheet |
Written by Jean-Baptiste Nivoit. This is the style for Lout files. |
Mail Folder (mail.ssh )
|
Style Sheet |
To use from elm and others, it is better to specify -g -Email ,
since the file sent to printer is no longer truly a mail folder.
This style also suits to news. --strip options are also useful
(they strip "useless" headers).
Whenever the changes of encoding are clear, a2ps sets itself the encoding for the parts concerned. Tag 1 is the subject, and Tag 2 the author of the mail/news. Note: This style sheet is _very_ difficult to write. Please don't report behavior you don't like. Just send me improvements, or write a Bison parser for mails. |
Makefile (make.ssh )
|
Style Sheet |
Special tokens, and non terminal declarations are highlighted. |
Management Information Base (mib.ssh )
|
Style Sheet |
Written by Kelly Wiles. The MIB file is of ASN.1 syntax. |
Maple (maple.ssh )
|
Style Sheet |
Written by Richard J Mathar. Some classical program names, and/or builtins, are highlighted in the second level of pretty-printing. |
MATLAB 4 (matlab4.ssh )
|
Style Sheet |
Written by Marco De la Cruz. Note that comments in the code should have a space after the %. |
Modula 2 (modula2.ssh )
|
Style Sheet |
Written by Peter Bartke. |
Modula 3 (modula3.ssh )
|
Style Sheet |
Modula-3 is a member of the Pascal family of languages. Designed in
the late 1980s at Digital Equipment Corporation and Olivetti, Modula-3
corrects many of the deficiencies of Pascal and Modula-2 for practical
software engineering. In particular, Modula-3 keeps the simplicity of
type safety of the earlier languages, while providing new facilities
for exception handling, concurrency, object-oriented programming, and
automatic garbage collection. Modula-3 is both a practical
implementation language for large software projects and an excellent
teaching language.
This sheet was designed based on Modula 3 home page. |
o2c (o2c.ssh )
|
Style Sheet |
Oberon (oberon.ssh )
|
Style Sheet |
Created by N. Wirth, Oberon is the successor of the Pascal and
Modula-2 family of programming languages. It was specifically designed
for systems programming, and was used to create the Oberon system in
cooperation with J. Gutknecht. A few years later, the Oberon language
was extended with additional object-oriented features to result in the
programming language Oberon-2.
Implementation of the sheet based on The Oberon Reference Site. |
Objective C (objc.ssh )
|
Style Sheet |
Written by Paul Shum. |
OCaml (ocaml.ssh )
|
Style Sheet |
Written by Markus Mott. This style should also suit other versions of ML (caml light, SML etc.). |
OCaml Yacc (mly.ssh )
|
Style Sheet |
Written by Jean-Baptiste Nivoit. Should handle CAML Special Light parser files. |
Octave (octave.ssh )
|
Style Sheet |
Written by C.P. Earls. |
Oracle parameter file (initora.ssh )
|
Style Sheet |
Written by Pierre Mareschal. For init.ora parameter files. |
Oracle PL/SQL (plsql.ssh )
|
Style Sheet |
Written by Pierre Mareschal. This style is to be checked. |
Oracle SQL (sql.ssh )
|
Style Sheet |
Written by Pierre Mareschal. a2ps-sql Pretty Printer Version 1.0.0 beta - 18-MAR-97 For comments, support for - /*..*/ and //. This style is to be checked. |
Oracle SQL-PL/SQL-SQL*Plus (oracle.ssh )
|
Style Sheet |
Written by Pierre Mareschal. 18-MAR-97 For comments, support for - /*..*/ and //. This style is to be checked. |
Pascal (pascal.ssh )
|
Style Sheet |
The standard Pascal is covered by this style. But some extension have been added too, hence modern Pascal programs should be correctly handled. Heavy highlighting maps mathematical symbols to their typographic equivalents. |
Perl (perl.ssh )
|
Style Sheet |
Written by Denis Girou. As most interpreted languages, Perl is very free on its syntax, what leads to significant problems for a pretty printer. Please, be kind with our try. Any improvement is most welcome. |
PostScript (ps.ssh )
|
Style Sheet |
Only some keywords are highlighted, because otherwise listings are quickly becoming a big bold spot. |
PostScript Printer Description (ppd.ssh )
|
Style Sheet |
Support for Adobe's PPD files. |
Pov-Ray (pov.ssh )
|
Style Sheet |
Written by Jean-Baptiste Nivoit. Should handle Persistence Of Vision input files. |
PreScript (pre.ssh )
|
Style Sheet |
This style defines commands in the canonic syntax of a2ps.
It is meant to be used either as an input language, and to
highlight the table of contents etc.
It can be a good choice of destination language for people who want to produce text to print (e.g. pretty-printing, automated documentation etc.) but who definitely do not want to learn PostScript, nor to require the use of LaTeX. |
PreTeX (pretex.ssh )
|
Style Sheet |
This style sheets provides LaTeX-like commands to format text.
It is an alternative to the PreScript style sheet, in which formating
commands are specified in a more a2ps related syntax.
It provides by the use of LaTeX like commands, a way to describe the pages that this program should produce. |
Prolog (prolog.ssh )
|
Style Sheet |
Help is needed on this sheet. |
Promela (promela.ssh )
|
Style Sheet |
There is no way for this program to highlight send and receive primitives. |
Python (python.ssh )
|
Style Sheet |
Python is an easy to learn, powerful programming language. It has
efficient high-level data structures and a simple but effective
approach to object-oriented programming. Python's elegant syntax and
dynamic typing, together with its interpreted nature, make it an ideal
language for scripting and rapid application development in many areas
on most platforms.
The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, and can be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation. The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications. |
Reference Card (card.ssh )
|
Style Sheet |
This style sheet is meant to process help messages generated by
Unix applications. It highlights the options (-short or -long),
and their arguments.
Normal use of this style sheet is through the shell script card
(part of the a2ps package), but a typical hand-driven use is:
program --help | a2ps -Ecard |
REXX (rexx.ssh )
|
Style Sheet |
Written by Alexander Mai. This style sheet supports REXX. You can get information about REXX from the REXX Language Association. |
Sather (sather.ssh )
|
Style Sheet |
Sather is an object oriented language designed to be simple,
efficient, safe, flexible and non-proprietary. One way of placing it
in the `space of languages' is to say that it aims to be as efficient
as C, C++, or Fortran, as elegant as and safer than Eiffel, and
support higher-order functions and iteration abstraction as well as
Common Lisp, CLU or Scheme.
Implementation of the sheet based on the Sather home page. Heavy highlighting uses symbols for common mathematical operators. |
Scheme (scheme.ssh )
|
Style Sheet |
This style sheet is looking for a maintainer and/or comments. |
SDL-88 (sdl88.ssh )
|
Style Sheet |
Written by Jean-Philippe Cottin. -strip-level=2 is very useful: it cancels the graphical information left by graphic editors. Only the pure specification is then printed. |
Sed (sed.ssh )
|
Style Sheet |
Comments and labels are highlighted. Other ideas are welcome! A lot of work is still needed. |
Shell (shell.ssh )
|
Style Sheet |
This style sheet is not meant to be used directly, but rather an as ancestor for shell style sheets. |
SQL 92 (sql92.ssh )
|
Style Sheet |
Written by Pierre Mareschal. 18-MAR-97 This style is to be checked. |
Standard ML (sml.ssh )
|
Style Sheet |
Written by Franklin Chen, Daniel Wang. This style sheet takes advantage of the Symbol font to replace many ASCII operators with their natural graphical representation. This is enabled only at heavy highlighting. |
Symbols (symbols.ssh )
|
Style Sheet |
This style sheet should be a precursor for any style sheet which uses LaTeX like symbols. |
TC Shell (tcsh.ssh )
|
Style Sheet |
Written by Jim Diamond. C shell with file name completion and command line editing. |
TeX (tex.ssh )
|
Style Sheet |
Written by Denis Girou.
This is the style for (La)TeX files.
It's mainly useful for people who develop (La)TeX packages.
With -g , common mathematical symbols are represented graphically.
|
Texinfo (texinfo.ssh )
|
Style Sheet |
Heavy highlighting prints the nodes on separate pages which title is the name of the node. |
TeXScript (texscript.ssh )
|
Style Sheet |
TeXScript is the new name of what used to be called PreScript. New PreScript has pure a2ps names, PreTeX has pure TeX names, and TeXScript mixes both. |
Tiger (tiger.ssh )
|
Style Sheet |
Tiger is a toy language that serves as example of the book Modern Compiler Implementation by Andrew W. Appel. |
tk (tk.ssh )
|
Style Sheet |
Written by Larry W. Virden. Since everything, or almost, is a string, what is printed is not always what you would like. |
Tool Command Language (tcl.ssh )
|
Style Sheet |
Written by Larry W. Virden. Since everything, or almost, is a string, what is printed is not always what you would like. |
Unified Diff (udiff.ssh )
|
Style Sheet |
This style is meant to be used onto the output unidiffs, that is to say
output from diff -u .
Typical use of this style is: diff -u old new | a2ps -Eudiff The prologue |
Unity (unity.ssh )
|
Style Sheet |
Written by Jean-Philippe Cottin.
The graphic conversion of the symbols (option -g ) is nice.
|
VERILOG (verilog.ssh )
|
Style Sheet |
Written by Edward Arthur. This style is devoted to the VERILOG hardware description language. |
VHDL (vhdl.ssh )
|
Style Sheet |
Written by Thomas Parmelan. Non-textual operators are not highlighted. Some logical operators are printed as graphical symbols in the second level of pretty-printing. |
Visual Basic for Applications (vba.ssh )
|
Style Sheet |
Written by Dirk Eddelbuettel. |
Visual Tcl (vtcl.ssh )
|
Style Sheet |
Written by Phil Hollenback. All the Vtcl keywords that aren't in Tcl or TclX. |
VRML (vrml.ssh )
|
Style Sheet |
Written by Nadine Richard. According to Grammar Definition Version 2.0 ISO/IEC CD 14772. |
wdiff (wdiff.ssh )
|
Style Sheet |
This style is meant to be used onto the output of Franc,ois Pinard's
program wdiff . wdiff is a utility that underlines the differences
of words between to files. Where diff make only the difference between
lines that have changed, wdiff reports words that have changed inside the lines.
Typical use of this style is: wdiff old new | a2ps -Ewdiff
|
XS (xs.ssh )
|
Style Sheet |
Written by Kestutis Kupciunas. This style covers Perl XS language. |
Yacc (yacc.ssh )
|
Style Sheet |
Special tokens, and non terminal declarations are highlighted. |
Z Shell (zsh.ssh )
|
Style Sheet |
Zsh is a UNIX command interpreter (shell) usable as an interactive
login shell and as a shell script command processor. Of the standard
shells, zsh most closely resembles ksh but includes many enhancements.
Zsh has comand line editing, builtin spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and a host of other features.
This style sheet highlights some classical program names and builtins in the second level of pretty-printing. |
This section presents a few style sheets that define page description languages (compared to most other style sheet meant to pretty print source files).
The style sheet Symbol
introduces easy to type keywords to obtain
the special characters of the PostScript font Symbol
. The
keywords are named to provide a LaTeX taste. These keywords are also
the names used when designing a style sheet, hence to get the full list,
see A Bit of Syntax.
If you want to know the correspondence, it is suggested to print the
style sheet file of Symbol
:
a2ps -g symbol.ssh
PreScript
has been designed in conjunction with a2ps. Since
bold sequences, special characters etc. were implemented in a2ps, we
thought it would be good to allow direct access to those features:
PreScript
became an input language for a2ps, where special
font treatments are specified in an ssh
syntax (see Style Sheets Implementation).
The main advantages for using PreScript
are:
It can be a good candidate for generation of PostScript output (syntactic pretty-printers, generation of various reports etc.).
Every command name begins with a backslash (\
). If the command
uses an argument, it is given between curly braces with no spaces
between the command name and the argument.
The main limit on PreScript
is that no command can be used inside
another command. For instance the following line will be badly
interpreted by a2ps:
\Keyword{Problems using \keyword{recursive \copyright} calls}
The correct way to write this in PreScript
is
\Keyword{Problems using} \keyword{recursive} \copyright \Keyword{calls}.
Everything from an unquoted % to the end of line is ignored (comments).
These commands required arguments.
\keyword{text}
\Keyword{text}
\comment{text}
\Comment{text}
--strip
is used.
\label{text}
\Label{text}
\string{text}
\error{text}
\symbol{text}
\header{text}
\footer{text}
\encoding{key}
PreScript
and a2ps can be used for one-the-fly
formating. For instance, on the passwd
file:
ypcat passwd | awk -F: \ '{print "\Keyword{" $5 "} (" $1 ") \rightarrow\keyword{" $7 "}"}'\ | a2ps -Epre -P
The aim of the PreTeX style sheet is to provide something similar to
PreScript
, but with a more LaTeX like syntax.
$
is ignored in PreTeX
for compatibility with LaTeX,
and %
introduces a comment. Hence they are the only symbols which
have to be quoted by a \
. The following characters should also be
quoted to produce good LaTeX files, but are accepted by
PreScript
: _
, &
, #
.
Note that inside a command, like \textbf
, the quotation
mechanism does not work in PreScript
(\textrm{#$%}
writes #$%
) though LaTeX still requires quotation. Hence whenever
special characters or symbols are introduced, they should be at the
outer most level.
These commands required arguments.
\section{Title}
\subsection{Title}
\subsubsection{Title}.
\textbf{text}
\textit{text}
\textbi{text}
\textrm{text}
\textsy{text}
Symbol
).
\header{text}
\footer{text}
\verb+text+
\verb+quoted string+
+
can be any symbol in
+
, !
, |
, #
, =
.
\begin{document}
\end{document}
\begin{itemize}
\end{itemize}
\begin{enumerate}
\end{enumerate}
\begin{description}
\end{description}
The following symbols, inherited from the style sheet Symbol
, are
not supported by LaTeX:
\Alpha
, \apple
, \Beta
, \carriagereturn
,
\Chi
, \Epsilon
, \Eta
, \florin
, \Iota
,
\Kappa
, \Mu
, \Nu
, \Omicron
, \omicron
,
\radicalex
, \register
, \Rho
, \suchthat
,
\Tau
, \therefore
, \trademark
, \varUpsilon
,
\Zeta
.
LaTeX is more demanding about special symbols. Most of them must be
in so-called math mode, which means that the command must be inside
$
signs. For instance, though
If \forall x \in E, x \in F then E \subseteq F.
is perfectly legal in PreTeX, it should be written
If $\forall x \in E, x \in F$ then $E \subseteq F$.
for LaTeX. Since in PreTeX every $
is discarded (unless
quoted by a \
), the second form is also admitted.
TeXScript
is a replacement of the old version of
PreScript
: it combines both the a2ps-like and the
LaTeX-like syntaxes through inheritance of both PreScript
and
PreTeX
.
In addition it provides commands meant to ease processing of file for a2ps by LaTeX.
Everything between %%TeXScript:skip
and %%TeXScript:piks
will be ignored in TeXScript
, so that there can be inserted
command definitions for LaTeX exclusively.
The commands \textbi
(for bold-italic) and \textsy
(for
symbol) do not exist in LaTeX. They should be defined in the
preamble:
%%TeXScript:skip \newcommand{\textbi}[1]{\textbf{\textit{#1}}} \newcommand{\textsy}[1]{#1} %%TeXScript:piks
There is no way in TeXScript to get an automatic numbering. There is
no equivalent to the LaTeX environment enumerate
. But every
command beginning by \text
is doubled by a command beginning by
\magic
. a2ps behaves the same way on both families of commands.
Hence, if one specifies that arguments of those functions should be
ignored in the preamble of the LaTeX document, the numbering is
emulated. For instance
\begin{enumerate} \magicbf{1.}\item First line \magicbf{2.}\item Second line \end{enumerate}
will be treated the same way both in TeXScript and LaTeX.
\header
and \footer
, are not understood by LaTeX.
A face is an attribute given to a piece of text, which specifies how it should look like. Since a2ps is devoted to pretty-printing source files, the faces it uses are related to the syntactic entities that can be encountered in a file.
The faces a2ps uses are:
Plain
Keyword
Keyword_strong
Comment
Comment_strong
--strip-level
. Hence, never use these faces
just because you think they look better on, say, strings.
Label
Label_strong
String
Error
Actually, there is also the face Symbol
, but this one is
particular: it is not legal changing its font.
Every style sheet has both a key, and a name. The name can be clean and beautiful, with any character you might want. The key is in fact the prefix part of the file name, and is alpha-numerical, lower case, and less than 8 characters long.
Anywhere a2ps needs to recognize a style sheet by a name, it
uses the key (in the sheets.map
file, with the option -E
,
etc.).
As an example, C++ is implemented in a file called cxx.ssh
, in
which the name is declared to be C++
.
The rationale is that not every system accepts any character in the file
name (e.g., no +
in MS-DOS). Moreover, it allows to make
symbolic links on the ssh files (e.g., ln -s cxx.ssh c++.ssh
let's you use -E c++
).
ssh files can include the name of its author, a version number, a documentation note and a requirement on the version of a2ps. For instance, if a style sheet requires a2ps version 4.9.6, then a2ps version 4.9.5 will reject it.
If the style is case insensitive, then matching is case insensitive (keywords, operators and sequences).
A P-rule (Pretty printing rule), or rule for short, is a structure which consists of two items:
Just a short example: (foo, bar, Keyword_strong)
as a rule
means that every input occurrence of foo
will be replaced by
bar
, written with the Keyword_strong
face.
If the destination string is empty, then a2ps will use the source string. This is different from giving the source string as a destination string if the case is different. An example will make it fairly clear.
Let foobar
be a case insensitive style sheet including the
rules (foo, "", Keyword)
and (bar, bar, Keyword)
. Then,
on the input FOO BAR
, a2ps will produce FOO bar
in
Keyword
.
a2ps implements two different ways to match a string. The difference
comes from that some keywords are sensitive to the delimiters around
them (such as unsigned
and int
in C
, which are
definitely not the same thing as unsignedint
), and others not (in
C
, !=
is "different from" both in a != b
and
a!=b
).
The first ones are called keywords in a2ps jargon, and the seconds are operators. Operators are matched anywhere they appear, while keywords need to have separators around them (see Alphabets).
Let us give a more complicated example: that of the Yacc
rules.
A rule in Yacc
is of the form:
a_rule : part1 part2 ;
Suppose you want to highlight these rules. To recognize them, you will write a regular expression specifying that:
The regexp you want is: /^[a-zA-Z0-9_]*[\t ]*:/
. But with the
rule
/^[a-zA-Z0-9_]*[\t ]*:/, "", Label_strong
the blanks and the colon are highlighted too. Hence you need to specify some parts in the regexp (see Back-reference Operator), and use a longer list of destination strings. The correct rule is
(/^([a-zA-Z0-9_]*)([\t ]*:)/, \1 Label_strong, \2 Plain)
Since it is a bit painful to read, regexps can be spread upon several lines. It is strongly suggested to break them by groups, and to document the group:
(/^([a-zA-Z0-9_]*)/ # \1. Name of the rule /([\t ]*:)/ # \2. Trailing space and colon \1 Label_strong, \2 Plain)
A sequence is a string between two markers, along with a
list of exceptions. A marker is a fixed string. Typical examples are
comments, string (with usually "
as opening and closing markers,
and \\
and \"
as exceptions) etc. Three faces are used:
one for the initial marker, one for the core of the sequence, and a last
one for the final maker.
There are two levels of pretty-printing encoded in the style sheets. By
default, a2ps uses the first level, called normal, unless the
option -g
is specified, in which case, heavy highlighting
is invoked, i.e., optional keywords, operators and sequences are
considered.
In the previous section (see Style sheets semantics) were explained the various items needed to understand the machinery involved in pretty printing. Here, their implementation, i.e., how to write a style sheet file, is explained. The next section (see A tutorial on style sheets), exposes a step by step simple example.
Here are the lexical rules underlying the style sheet language:
#
introduces a comment, ended at the end of the line.
#
, "
,
,
, (
, )
, +
and /
. Any other
character is a regular character.
alphabet
,alphabets
,are
,case
,documentation
,end
,exceptions
,first
,in
,insensitive
,is
,keywords
,operators
,optional
,second
,sensitive
,sequences
,style
Comment
,Comment_strong
,Encoding
,Error
,Index1
,Index2
,Index3
,Index4
,Invisible
,Keyword
,Keyword_strong
,Label
,Label_strong
,Plain
,String
,Symbol
,Tag1
,Tag2
,Tag3
,Tag4
C-char
,C-string
It is a good idea to print the style sheet---
,\Alpha
,\Beta
,\Chi
,\Delta
,\Downarrow
,\Epsilon
,\Eta
,\Gamma
,\Im
,\Iota
,\Kappa
,\Lambda
,\Leftarrow
,\Leftrightarrow
,\Mu
,\Nu
,\Omega
,\Omicron
,\Phi
,\Pi
,\Psi
,\Re
,\Rho
,\Rightarrow
,\Sigma
,\Tau
,\Theta
,\Uparrow
,\Upsilon
,\Xi
,\Zeta
,\aleph
,\alpha
,\angle
,\approx
,\beta
,\bullet
,\cap
,\carriagereturn
,\cdot
,\chi
,\circ
,\clubsuit
,\cong
,\copyright
,\cup
,\delta
,\diamondsuit
,\div
,\downarrow
,\emptyset
,\epsilon
,\equiv
,\eta
,\exists
,\florin
,\forall
,\gamma
,\geq
,\heartsuit
,\in
,\infty
,\int
,\iota
,\kappa
,\lambda
,\langle
,\lceil
,\ldots
,\leftarrow
,\leftrightarrow
,\leq
,\lfloor
,\mu
,\nabla
,\neq
,\not
,\not\in
,\not\subset
,\nu
,\omega
,\omicron
,\oplus
,\otimes
,\partial
,\perp
,\phi
,\pi
,\pm
,\prime
,\prod
,\propto
,\psi
,\radicalex
,\rangle
,\rceil
,\register
,\rfloor
,\rho
,\rightarrow
,\sigma
,\sim
,\spadesuit
,\subset
,\subseteq
,\suchthat
,\sum
,\supset
,\supseteq
,\surd
,\tau
,\theta
,\therefore
,\times
,\trademark
,\uparrow
,\upsilon
,\varUpsilon
,\varcopyright
,\vardiamondsuit
,\varphi
,\varpi
,\varregister
,\varsigma
,\vartheta
,\vartrademark
,\vee
,\wedge
,\wp
,\xi
,\zeta
symbols.ssh
to see
them:
a2ps symbols.ssh
"
, and may contain anything.
Regular C
escaping mechanism is used.
/
, and may contain
anything. Regular C
escaping mechanism is used. Regexps can be
split in several parts, a` la C strings (i.e., /part 1/ /part
2/
).
"
).
The definition of the name of the style sheet is:
style
nameis
# body of the style sheetend
style
The following constructions are optional:
version
version is version-number
written
written by authors
Giving your email is useful for bug reports about style sheets.
written by "Some Body <Some.Body@some.whe.re>"
requires
requires a2ps a2ps-version-number
documentation
documentation is strings end documentationstrings may be a list of strings, without comas, in which case new lines are automatically inserted between each item. See Documentation Format, for details on the format.
Please, write useful comments, not This style is devoted to C
files
, since the name is here for that, nor Report errors to
mail@me.somewhere
, since written by
is there for that.
documentation is "Not all the keywords are used, to avoid too much" "bolding. Heavy highlighting (code(-g)code), covers" "the whole language." end documentation
There are two things a2ps needs to know: what is symbol consistent, and whether the style is case insensitive.
alphabet
first alphabet is string second alphabet is string
If both are identical, you may use the shortcut
alphabets are string
The default alphabets are
first alphabet is "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_" second alphabet is "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\ 0123456789"
Note that it is on purpose that no characters interval are used.
case
case insensitive # e.g., C, C++ etc. case sensitive # e.g., Perl, Sather, Java etc.
The default is case insensitive
.
It is possible to extend an existing style. The syntax is:
ancestors are ancestor_1[, ancestor_2...] end ancestors
where ancestor1 etc. are style sheet keys.
For semantics, the rules are the following:
As an example, both C++
and Objective C
style sheets
extend the C
style sheet:
style "Objective C" is #[...] ancestors are c end ancestors #[...] end style
To the biggest surprise of the author, mutually dependent style sheets do work!
See P-Rules, for the definition of P-rule.
Because of various short cuts, there are many ways to declare a rule:
rules ::= rule_1,
rule_2... rule ::=(
lhs rhs)
| lhs srhs ; lhs ::= string | regex ; rhs ::= srhs,
... srhs ::= latex-keyword | expansion face expansion ::= string |\
num | <nothing>; face ::= face-keyword | <nothing>;
The rules are the following:
#define RE_SYNTAX_A2PS \ (/* Allow char classes. */ \ RE_CHAR_CLASSES \ /* Be picky. */ \ | RE_CONTEXT_INVALID_OPS \ /* Allow intervals with `{' and `}', forbid invalid ranges. */\ | RE_INTERVALS | RE_NO_BK_BRACES | RE_NO_EMPTY_RANGES \ /* `(' and `)' are the grouping operators. */ \ | RE_NO_BK_PARENS \ /* `|' is the alternation. */ \ | RE_NO_BK_VBAR)
Basically it means that all of the possible operators are used, and that
they are in non-backslashed form. For instance (
and )
stand for the group operator, while \\(
stands for the character
(
. See Regular Expression Syntax, for a detailed description of the regular
expressions.
(/fo*/, NULL, Keyword)
applied on the source
fooooo
produces fooooo
in Keyword
.
PLAIN
is used.
Basically, keywords and operators are lists of rules. The syntax is:
keywords are rules end keywords
or
keywords in face-keyword are rules end keywords
in which case the default face is set to face-keyword.
As an example:
keywords in Keyword_strong are /foo*/, "bar" "BAR" Keyword, -> \rightarrow end keywords
is valid.
The syntax for the operators is the same, and both constructs can be
qualified with an optional
flag, in which case they are taken
into account in the heavy highlighting mode (see Pretty Print Options).
This is an extract of the C
style sheet:
optional operators are -> \rightarrow, && \wedge, || \vee, != \neq, == \equiv, # We need to protect these, so that <= is not replaced in <<= <<=, >>=, <= \leq, >= \geq, ! \not end operators
Note how <<=
and >>=
are protected (there are defined to
be written as is when met in the source). This is to prevent the two
last characters of <<=
from being converted into a `less or
equal' sign.
The order in which you define the elements of a category (but the
sequences) does not matter. But since a2ps sorts them at run time, it
may save time if the alphabetical C
-order is more or less
followed.
You should be aware that when declaring a keyword with a regular expression as lhs, then a2ps automatically makes this expression matching only if there are no character of the first alphabet both just before, and just after the string.
In term of implementation, it means that
keywords are /foo|bar/ end keywords
is exactly the same as
operators are /\\b(foo|bar)\\b/ end operators
This can cause problems if you use anchors (e.g. $
, or ^
)
in keywords: the matcher will be broken. In this particular case,
define your keywords as operators, taking care of the \\b
by
yourself.
See Match-word-boundary Operator, for details on \b
.
Sequences admit several declarations too:
sequences ::= sequences are sequence_1,
sequence_2... end sequences sequence ::= rule in_face close_opt exceptions_opt |C-string
|C-char
; close_opt ::= rule | closers are rules end closers | <nothing> ; exceptions_opt ::= exceptions are rules end exceptions | <nothing> ;
The rules are:
"\n"
(i.e., end-of-line) is used.
As a first example, here is the correct definition for a C
string:
sequences are "\"" Plain String "\"" Plain exceptions are "\\\\", "\\\"" end exceptions end sequencesSince a great deal of languages uses this kind of constructs, you may use
C-string
to mean exactly this, and C-char
for
manifest characters defined the C
way.
The following example comes from ssh.ssh
, the style sheet for
style sheet files, in which there are two kinds of pseudo-strings: the
strings ("example"
), and the regular expressions
(/example/
). We do not want the content of the pseudo-strings in
the face String
.
sequences are # The comments "#" Comment, # The name of the style sheet "style " Keyword_strong (Label + Index1) " is" Keyword_strong, # Strings are exactly the C-strings, though we don't want to # have them in the "string" face "\"" Plain "\"" exceptions are "\\\\", "\\\"" end exceptions, # Regexps "/" Plain "/" exceptions are "\\\\", "\\\/" end exceptions end sequences
The order between sequences does matter. For instance in Java,
/**
introduces strong comments, and /*
comments.
/**
must be declared before /*
, or it will be
hidden.
There are actually some sequences that could have been implemented as
operators with a specific regular expression (that goes up to the
closer). Nevertheless be aware of a big difference: regular expression
are applied to a single line of the source file, hence, they cannot
match on several lines. For instance, the C
comments,
/* * a comment */
cannot be implemented with operators, though C++
comments can:
// // a comment //
Once your style sheet is written, you may want to let a2ps perform simple tests on it (e.g., checking there are no rules involving upper case characters in a case insensitive style sheet, etc.). These tests are performed when verbosity includes the style sheets.
you may also want to use the special convention that when a style sheet is required with a suffix, then a2ps will not look at it in its library path, but precisely from when you are.
Suppose for instance you extended the c.ssh
style sheet, which is
in the current directory, and is said case insensitive. Run
ubu $ a2ps foo.c -Ec.ssh -P void -v sheets # Long output deleted Checking coherence of "C" (c.ssh) a2ps: c.ssh:`FILE' uses upper case characters a2ps: c.ssh:`NULL' uses upper case characters "C" (c.ssh) is corrupted. ---------- End of Finalization of c.ssh
Here, it is clear that C
is not case insensitive.
In this section a simple example of style sheet is entirely covered:
that of ChangeLog
files.
ChangeLog
files are some kind of memory of changes done to files,
so that various programmers can understand what happened to the sources.
This helps a lot, for instance, in guessing what recent changes may have
introduced new bugs.
First of all, here is a sample of a ChangeLog
file, taken from
the misc/
directory of the original a2ps package:
Sun Apr 27 14:29:22 1997 Akim Demaille <demaille@inf.enst.fr> * base.ps: Merged in color.ps, since now a lot is common [added box and underline features]. Fri Apr 25 14:05:20 1997 Akim Demaille <demaille@inf.enst.fr> * color.ps: Added box and underline routines. Mon Mar 17 20:39:11 1997 Akim Demaille <demaille@gargantua.enst.fr> * base.ps: Got rid of CourierBack and reencoded_backspace_font. Now the C has to handle this by itself. Sat Mar 1 19:12:22 1997 Akim Demaille <demaille@gargantua.enst.fr> * *.enc: they build their own dictionaries, to ease multi lingual documents.
The syntax is really simple: A line specifying the author and the date of the changes, then a list of changes, all of them starting with an star followed by the name of the files concerned, then optionally between parentheses the functions affected, and then some comments.
Quite naturally the style will be called ChangeLog
, hence:
style ChangeLog is written by "Akim Demaille <demaille@inf.enst.fr>" version is 1.0 requires a2ps 4.9.5 documentation is "This is a tutorial style sheet.\n" end documentation ... end style
A first interesting and easy entry is that of function names, between
(
and )
:
sequences are "(" Plain Label ")" Plain end sequences
A small problem that may occur is that there can be several functions mentioned separated by commas, that we don't want to highlight this way. Commas, here, are exceptions. Since regular expressions are not yet implemented in a2ps, there is a simple but stupid way to avoid that white spaces are all considered as part of a function name, namely defining two exceptions: one which captures a single comma, and a second, capturing a comma and its trailing space.
For the file names, the problem is a bit more delicate, since they may
end with :
, or when starts the list of functions. Then, we
define two sequences, each one with one of the possible closers, the
exceptions being attached to the first one:
sequences are "* " Plain Label_strong ":" Plain exceptions are ", " Plain, "," Plain end exceptions, "* " Plain Label_strong " " Plain end sequences
Finally, let us say that some words have a higher importance in the core of text: those about removing or adding something.
keywords in Keyword_strong are add, added, remove, removed end keywords
Since they may appear in lower or upper, of mixed case, the style will be defined as case insensitive.
Finally, we end up with this style sheet file, in which an optional
highlighting of the mail address of the author is done. Saving the file
is last step. But do not forget that a style sheet has both a name as
nice as you may want (such as Common Lisp
), and a key on which
there are strict rules: the prefix must be alpha-numerical, lower case,
with no more than 8 characters. Let's chose chlog.ssh
.
# This is a tutorial on a2ps' style sheets style ChangeLog is written by "Akim Demaille <demaille@inf.enst.fr>" version is 1.0 requires a2ps 4.9.5 documentation is "Second level of high lighting covers emails." end documentation sequences are "(" Plain Label ")" Plain exceptions are ", " Plain, "," Plain end exceptions, "* " Plain Label_strong ":" Plain exceptions are ", " Plain, "," Plain end exceptions, "* " Plain Label_strong " " Plain end sequences keywords in Keyword_strong are add, added, remove, removed end keywords optional sequences are < Plain Keyword > Plain end sequences end style
As a last step, you may which to let a2ps check your style sheet, both its syntax, and common errors:
ubu $ a2ps -vsheet -E/tmp/chlog.ssh ChangeLog -P void Long output deleted Checking coherence of "ChangeLog" (/tmp/chlog.ssh) "ChangeLog" (/tmp/chlog.ssh) is sane. ---------- End of Finalization of /tmp/chlog.ssh
It's all set, your style sheet is ready!
sheets.map
The last touch is to include the pattern rules about ChangeLog
files (which could appear as ChangeLog.old
etc.) in
sheets.map
:
# ChangeLog files chlog: /ChangeLog*/
This won't work... Well, not always. Not for instance if you print
misc/ChangeLog
. This is not a bug, but truly a feature, since
sometimes one gets more information about the type of a file from its
path, than from the file name.
Here, to match the preceding path that may appear, just use *
:
# ChangeLog files chlog: /*ChangeLog*/
If you want to be more specific (FooChangeLog
should not
match), use:
# ChangeLog files chlog: /ChangeLog*/ /*\/ChangeLog*/
The example we have presented until now uses only basic features, and does not take advantage of the regexp. In this section we should how to write more evolved pretty printing rules.
The target will be the lines like:
Sun Apr 27 14:29:22 1997 Akim Demaille <demaille@inf.enst.fr> Fri Apr 25 14:05:20 1997 Akim Demaille <demaille@inf.enst.fr>
There are three fields: the date, the name, the mail. These lines all
start at the beginning of line. The last field is the easier to
recognize: is starts with a <
, and finishes with a >
. Its
rule is then /<[^>]+>/
. It is now easier to specify the second:
it is composed only of words, at least one, separated by blanks, and is
followed by the mail: /[[:alpha:]]+([ \t]+[[:alpha:]]+)*/
.
To concatenate the two, we introduce optional blanks, and we put each one
into a pair of (
-)
to make each one a recognizable
part:
([[:alpha:]]+([ \t]+[[:alpha:]]+)*) (.+) (<[^>]+>)
Now the first part is rather easy: it starts at the beginning of the line, finishes with a digit. Once again, it is separated from the following field by blanks. Split by groups (see Grouping Operators), we have:
^ ([^\t ].*[0-9]) ([ \t]+) ([[:alpha:]]+([ \t]+[[:alpha:]]+)*) (.+) (<[^>]+>)
Now the destination is composed of back references to those groups, together with a face:
# We want to highlight the date and the maintainer name optional operators are (/^([^\t ].*[0-9])/ # \1. The date /([ \t]+)/ # \2. Spaces /([[:alpha:]]+([ \t]+[[:alpha:]]+)*)/ # \3. Name /(.+)/ # \5. space and < /(<[^>]+)>/ # \6. email \1 Keyword, \2 Plain, \3 Keyword_strong, \5 Plain, \6 Keyword, > Plain) end operators
Notice the way regexps are split, to ease reading.
This section is meant for people who wish to contribute style sheets. There is a couple of additional constraints, explained here.
sheets.map
Entries
sheets.map
lines that correspond to your
style sheet.
Finally, make sure your style sheet behaves well! (see Checking a Style Sheet)
This chapter is devoted to the information which is only relevant to PostScript.
To read this section, the reader must understand what DSC are (see Glossary).
Why are there good PostScript files, easy to post-process, and bad files that none of my tools seem to understand? They print fine though!
Once you understood that PostScript is not a page description format (like PDF is), you'll have understood most of the problem. Let's imagine for a second that you are a word processor.
The user asks you to print his/her 100 page document in PostScript. Up to page 50, there are few different fonts used. Then, on pages 51 to 80, there are now many different heavy fonts.
When/where will you download the fonts?
The most typical choice, sometimes called Optimize for Speed, is, once you arrived to page 51, to download those fonts once for the rest of the document. The global processing chain will have worked quite quickly: little effort from the software, same from the printer; better yet: you can start sending the file to the printer even before it is finished! The problem is that this is not DSC conformant, and it is easy to understand why: if somebody wants to print only the page 60, then s/he will lack the three fonts which were defined in page 51... This document is not page independent.
Another choice is to download the three fonts in each page ranging from 51 to 80, that is the PostScript file contains 30 times the definition of each font. It is easy for the application to do that, but the file is getting real big, and the printer will have to interpret 30 times the same definitions of fonts. But it is DSC conformant! And you can still send the file while you make it.
Now you understand why
Non DSC conformant files are not necessarily badly designed files from broken applications.
They are files meant to be sent directly to the printer (they are still perfect PostScript files after all!), they are not meant to be post-processed. And the example clearly shows why they are right.
There is a third possibility, sometimes called Optimize for Portability: downloading the three fonts in the prologue of the document, i.e., the section before the first page where are given all the common definitions of the whole file. This is a bit more complicated to implement (the prologue, which is issued first though, grows at the same time as you process the file), and cannot be sent concurrently with the processing (you have to process the whole file to design the prologue). This file is small (the fonts are downloaded once only), and DSC conformant. Well, there are problems, of course... You need to wait before sending the output, it can be costly for the computer (which cannot transfer as it produces), and for the printer (you've burnt quite a lot of RAM right since the beginning just to hold fonts that won't be used before page 51... This can be a real problem for small printers).
This is what a2ps does.
If should be clear that documents optimized for speed should never escape the way between the computer and the printer: no post-processing is possible.
What you should remember is that some applications offer the possibility to tune the PostScript output, and they can be praised for that. Unfortunately, when these very same applications don't automatically switch to "Optimize for Portability" when you save the PostScript file, and they can be criticized for that.
So please, think of the people after you: if you create a PostScript file meant to be exchanged, read, printed, etc; by other people: give sane DSC conformant, optimized for portability files.
Page device is a PostScript level 2 feature that offers an uniform interface to control the printer's output device. a2ps protects all page device options inside an if block so they have no effect in level 1 interpreters. Although all level 2 interpreters support page device, they do not have to support all page device options. For example some printers can print in duplex mode and some can not. Refer to the documentation of your printer for supported options.
Here are some usable page device options which can be selected with the
-S
option (--setpagedevice
). For a complete listing, see
PostScript Language Reference Manual (section 4.11 Device Setup
in the second edition, or section 6, Device Control in the third
edition).
Collate boolean
Duplex boolean
ManualFeed boolean
OutputFaceUp boolean
Tumble boolean
The statusdict
is a special storage entity in PostScript (called
a dictionary), in which some variables and operators determine the
behavior of the printer. This is an historic horror that existed before
page device definitions were defined. They are even more printer
dependent, and are provided only for the people who don't have a level
printer. In any case, refer to the documentation of your printer for
supported options.
Here are some statusdict definitions in which you might be interested:
manualfeed boolean
--statusdict=manualfeed::true
.
setmanualfeed boolean
--statusdict=setmanualfeed:true
.
setduplexmode boolean
--statusdict=setduplexmode:true
.
Nevertheless, here are some tips on how to design your PostScript
styles. It is strongly recommended to use gray.pro
or
color.pro
as a template.
There are two PostScript instructions you might want to use in your new PostScript prologue:
setgray
setrgbcolor
BG
and FG
, but
both use an argument as in setrgbcolor
. So if you wanted a gray
shade, just give three times the same ratio.
All a2ps files have two parts, one being the comments, and the other being the content, separated by the following line:
% code follows this line
It is pretty known that satisfying the various human tastes is an NEXPTIME-hard problem, so a2ps offers ways to customize its output through the prologue files. But since the authors feel a little small against NEXPTIME, they agreed on the fact that you are the one who will design the look you like.
Hence in this section, you will find what you need to know to be able to customize a2ps output.
Basically, a2ps uses faces which are associated to their "meaning" in the text. a2ps let's you change the way the faces look.
There are three things that define a face:
Hence, never set the font by yourself, but ask a2ps to do it. This is done through a line:
%Face: face real-font-name size
This line tells a2ps that the font of face is real-font-name. It will replace this line by the correct PostScript line to call the needed font, and will do everything needed to set up the font.
The size of the text body is bfs
.
true
to BG
:
0.8 0.8 0 true BG
BG
with
false
:
false BG
BG
, call FG
with an RGB ratio:
0 0.5 0 FG
UL
requires a boolean argument, depending whether you want
or not the current face to be underlined.
true UL
BX
let's a face have a box drawn around.
Prologue files for a2ps must have pro
as suffix. Documentation
(reported with --list-prologues
) can be included in the comment
part:
Documentation This prologue is the same as the prologue code(pb)code, but using the bold version of the fonts. EndDocumentation % code follows this lineSee Documentation Format, for more on the format.
We strongly suggest our readers not to start from scratch, but to copy
one of the available styles (see the result of a2ps
--list=prologues
), to drop it in one of a2ps directories (say
$HOME/.a2ps
, and to patch it until you like it.
Here, we will start from color.pro
, trying to give it a funky
look.
Say you want the keywords to be in Helvetica, drawn in a flashy pink on a light green. And strong keywords, in Times Bold Italic in brown on a soft Hawaiian sea green (you are definitely a fine art amateur).
Then you need to look for k
and K
:
/k { false BG 0 0 0.9 FG %Face: Keyword Courier bfs Show } bind def /K { false BG 0 0 0.8 FG %Face: Keyword_strong Courier-Bold bfs Show } bind def
and turn it into:
/k { 0.2 1 0.2 true BG 1 0.2 1 FG %Face: Keyword Helvetica bfs Show } bind def /K { 0.4 0.2 0 true BG 0.5 1 1 FG %Face: Keyword_strong Times-BoldItalic bfs Show } bind def
Waouh! It looks great!
A bit trickier: let change the way the line numbers are printed.
First, let's look for the font definition:
%%BeginSetup % The font for line numbering /f# /Helvetica findfont bfs .6 mul scalefont def %%EndSetup
Let it be in Times, twice bigger than the body font.
%%BeginSetup % The font for line numbering /f# /Times-Roman findfont bfs 2 mul scalefont def %%EndSetup
How about its foreground color?
% Function print line number (<string> # -) /# { gsave sx cw mul 2 div neg 0 rmoveto f# setfont 0.8 0.1 0.1 FG c-show grestore } bind def
Let it be blue. Now you know the process: just put 0 0 1
as
FG
arguments.
This chapter documents the various shell scripts or other tools that are
distributed with the a2ps package, but are not a2ps itself. The
reader should also look at the documentation of Ogonkify
(see top), written by Juliusz
Chroboczek.
card
Many users of a2ps have asked for a reference card, presenting a
summary of the options. In fact, something closely related to the
output of a2ps --help
.
The first version of this reference card was a PreScript file
(see PreScript) to be printed by a2ps. Very soon a much better
scheme was found: using a style sheet to pretty print directly the
output of a2ps --help
! A first advantage is then that the
reference cards can be printed in the tongue you choose.
A second was that this treatment could be applied to any application
supporting a --help
-like option.
card
card [options] applications [-- a2ps-options]
card
is a shell script which tries to guess how to get your
applications' help message (typically by the options --help
or -h
), and pretty prints it thanks to a2ps (or the content of
the environment variable A2PS
if it is set).
a2ps-options are passed to a2ps.
Supported options are:
-h | Option |
--help | Option |
print a short help message and exit successfully. |
-V | Option |
--version | Option |
report the version and exit successfully. |
-q | Option |
--quiet | Option |
--silent | Option |
Run silently. |
-D | Option |
--debug | Option |
enter in debug mode. |
-l language | Option |
--language=language | Option |
specify the language in which the reference card should be printed.
language should be the symbol used by LC_ALL etc.
(such as fr , it etc.).
If the applications don't support internationalization, English will be used. |
--command=command | Option |
Don't try to guess the applications' way to report their
help message, but rather use the call command.
A typical example is
card --command="cc -flags" |
It is possible to give options to a2ps (see Options) by
specifying them after --
. For instance
card gmake gtar --command="cc -flags" -- -Pdisplay
builds the reference card of GNU make
, GNU tar
(automatic
detection of --help
support), and cc
thanks to
-flags
.
card
Remember that card
runs the programs you give it, and the
commands you supplied. Hence if there is a silly programs that has a
weird behavior given the option -h
etc., beware of the result.
It is even clearer using --command
: avoid running card
--command="rm -rf *"
, because the result will be exactly what you think
it will be!
fixps
The shell script fixps
tries its best to fix common problems in
PostScript files that may prevent post processing. It makes heavy use
of the psutils
. It is a good idea to use fixps
in the
PostScript delegations.
It first tries to make simple fixes, but some really broken files may
require a much deeper treatment. If fixps
feels the need for
such a major surgery act, it may give up local changes and ask
Ghostscript
for a global rewriting.
fixps
fixps [options] [file]
sanitize the PostScript file (or of the standard input if no
file is given, or if file is -
).
Supported options are:
-h | Option |
--help | Option |
Print a short help message and a list of the fixes that are performed. Exit successfully. |
-V | Option |
--version | Option |
report the version and exit successfully. |
-D | Option |
--debug | Option |
enter in debug mode. |
-q | Option |
--quiet | Option |
--silent | Option |
Run silently. |
-o file | Option |
--output=file | Option |
specify the file in which is saved the output. |
-n | Option |
--no-fix | Option |
Don't actually fix the file but still honor all of the other
options. In particular, fixps -qn file is equivalent to
cat file .
|
-c | Option |
--check | Option |
--dry-run | Option |
Don't actually fix the file: just report the diagnostics.
Contrary to the option fixps -qc does absolutely nothing (while
it does take some time to do it nicely).
|
-f | Option |
--force | Option |
Ask ghoscript for a full rewrite of the file. The output
file is really sane, but can be much longer than the original. For this
reason and others, it is not always a good idea to make a full rewrite.
This option should be used only for files that give major problems.
|
fixnt
fixnt
(see its
http://www.itsm.uni-stuttgart.de/~bauer/fixnt.html, home page) is
maintained by Holger Bauer and
Michael Rath. It is meant to fix
the problems of the PostScript files generated by the Microsoft
PostScript driver under Windows NT (3.5 and 4.0).
fixps
is aware of the cases where fixnt
should be used,
hence you should not worry of when to use fixnt
.
fixnt
fixnt < file.ps
sanitize the PostScript file file.ps and produce the result on the standard output.
pdiff
The shell script pdiff
aims to pretty print diffs between files.
It basically uses GNU diff
(see diff) or GNU wdiff
(see wdiff) to extract the diff, then calls
a2ps with the correct settings to get a nice, printed contextual diff.
pdiff
pdiff [options] file-1 file-2 [-- a2ps-options]
make a pretty comparison between file-1 and file-2. a2ps-options are passed to a2ps.
Supported options are:
-h | Option |
--help | Option |
print a short help message and exit successfully. |
-V | Option |
--version | Option |
report the version and exit successfully. |
-q | Option |
--quiet | Option |
--silent | Option |
Run silently. |
-D | Option |
--debug | Option |
enter in debug mode. |
-w | Option |
--words | Option |
Look for words differences (default). White space differences are not considered. |
-l | Option |
--lines | Option |
Look for lines differences. |
It is possible to give options to a2ps (see Options) by
specifying them after --
. For instance
pdiff COPYING COPYING.LIB -- -1 -P display
Compares the files COPYING
and COPYING.LIB
, and prints it
on the printer display
(usually Ghostview
or gv
).
psmandup
I personally hate to print documents of hundreds of pages on a single sided printer. Too bad, here there are no Duplex printers. The idea is then simply first to print the odd pages, then the even in reversed order. To make sure one flips the page in the meanwhile, the second half should be printed from the manual feed tray.
Make a shell script that automates this, and you get psmandup
.
psmandup
psmandup [options] [file]
produce a manual duplex version of the PostScript file (or of the
standard input if no file is given, or if file is
-
). Once the first half is printed, put the sheet stack in the
manual feed tray for the second half5.
Be aware that there is a time out for manually fed jobs, usually short,
hence do not miss the moment when the printer asks for the stack. If
ever you missed that moment, see option --back
to recover the
second half.
Supported options are:
-h | Option |
--help | Option |
print a short help message and exit successfully. |
-V | Option |
--version | Option |
report the version and exit successfully. |
-q | Option |
--quiet | Option |
--silent | Option |
Run silently. |
-D | Option |
--debug | Option |
enter in debug mode. |
-o file | Option |
--output=file | Option |
specify the file in which is saved the output. |
-n | Option |
--no-fix | Option |
psmandup will fail on ill designed PostScript (well, actually the
psutils will). To avoid this, by default the PostScript file is
sanitized by fixps .
When given this option, don't run |
-f | Option |
--front | Option |
Output only the front pages, with no special PostScript feature request. |
-b | Option |
--back | Option |
Output only the back pages, with a manual feed request.
This option is especially useful when the manual feed time out expired before you could insert back the stack in the manual feed tray. |
psmandup
assumes the printer is Level 2, and supports manual
feeding. The file should be reasonably sane, otherwise
psmandup
fails miserably.
Typical use is
psmandup file.ps | lp
or can be put into a2ps' printer commands (see Your Printers).
psset
The shell script psset
inserts calls to setpagedevice
in a
PostScript file. This is useful for instance to add Tumble or Manual
feed request. Actually, psmandup
uses psset
.
You should know nevertheless that a2ps is able to make the calls to
setpagedevice
by itself, i.e., you can run a2ps
-SManualFeed foo
to print foo
onto the manually fed tray, or run
a2ps -s2 foo
to print Duplex. There are no need of psset
from a2ps.
psset
psset [options] [file]
produce a version of the PostScript file (or of the standard input
if no file is given, or if file is -
) that makes
protected calls to the PostScript operator setpagedevice
.
Typical use is making file print duplex, or on the manual tray
etc.
The call is protected so that the resulting file is safe, i.e., will
still be portable, even with requests such as -Sfoo:bar
.
It is safe to run psset
with no feature requests. Depending upon
the option --no-fix
, it is either equivalent to doing nothing, or
to running fixps
(see fixps).
Supported options are:
-h | Option |
--help | Option |
Print a short help message and exit successfully. |
-V | Option |
--version | Option |
report the version and exit successfully. |
-D | Option |
--debug | Option |
enter in debug mode. |
-q | Option |
--quiet | Option |
--silent | Option |
Run silently. |
-o file | Option |
--output=file | Option |
specify the file in which is saved the output. |
-n | Option |
--no-fix | Option |
psset will fail on ill designed PostScript. Actually it is the
psutils that fail. To avoid this, by default the PostScript file is
sanitized by fixps .
When given this option, don't run |
-S key:value | Option |
--setpagedevice=key:value | Option |
Insert a setpagedevice call setting key to value.
Multiple values accumulate. Lists of requests separated with ;
are valid (e.g., -SDuplex:true;Tumble:false ).
|
-a page | Option |
--at=page | Option |
Specify the page where the setpagedevice call should be done.
The page 0, which is the default, corresponds to the Setup
section of the document. More precisely, the insertion is performed at
the end of the Setup section, so that if there are multiple calls
to psset on the same document (which is of course, a bad idea),
the last call is winning.
In a typical use you should not change the page. |
-m | Option |
--manualfeed | Option |
Alias for -SManualFeed:true , i.e., the request to print using the
manual feed tray.
|
-s | Option |
--simplex | Option |
Alias for -SDuplex:false , i.e., force simplex printing.
|
-d | Option |
--duplex | Option |
Alias for -SDuplex:true;Tumble:false , i.e., the request to print
in duplex mode, binding along the long edge of the paper.
|
-t | Option |
--tumble | Option |
Alias for -SDuplex:true;Tumble:true , i.e., duplex printing
such that binding should happen on the short edge of the medium.
|
Please, before sending us mail, make sure the problem you have is not known, and explained. Moreover, avoid using the mailing list for asking question about the options, etc. It has been built for announces and suggestions, not to contact the authors.
Error related questions.
a2ps works OK, but the printer prints nothing.
There are two ways that printing can fail: silently, or with a diagnostic.
First, check that the printer received what you sent. a2ps may correctly do its job, but have the printer queue fail to deliver the job. In case of doubt, please check that the printer's leds blink (or whatever is its way to show that something is being processed).
If the printer does receive the job, but prints nothing at all, check
that you did not give exotic options to an old printer (typically, avoid
printing on two sides on a printer that does not support it). Avoid
using -S
, --setpagedevice
(see Page Device Options)
and --statusdict
(see Statusdict Options).
If the trouble persists, please try again but with the option
--debug
(a PostScript error handler is downloaded), and then send
us:
--debug
Though I ask a2ps to print Duplex via --sides
, the job is
printed Simplex.
If your printer is too old, then a2ps will not be able to send it the
code it needs when -s2
is specified. This is because your
printer uses an old and not standardized interface for special features.
So you need to
-s2
,
-SDuplex
,
--statusdict=setduplexmode:true
.
Since this is painful to hit, a User Option (see Your Shortcuts) should help.
Though I ask a2ps to print Simplex via --sides
, the job is
printed Duplex.
Actually when you require Simplex, a2ps issues nothing, for portability
reasons. Hence, if your printer is defaulted to Duplex, the job will be
Duplexed. So you have to force a2ps to issue the Simplex request with
-SDuplex:false
. The user options -=s1
and
-=simplex
have names easier to remember.
In the next version of a2ps this kind of portability problems will be fixed in a user friendly way.
When I print text files with a2ps, it prints beyond the frame of the paper.
You are most probably printing with a bad medium, for instance using A4
paper within a2ps, while your printer uses Letter paper. Some jet
printers have a small printable area, and a2ps may not expect it. In
both case, read Sheet Options, option --medium
for more.
What I get on the printer is long and incomprehensible. It does not seem to correspond to what I wanted to print.
You are probably printing a PostScript file or equivalent. Try to print
with -Z
: a2ps will try to do his best to find what is the
program that can help you (see Your Delegations). In case of doubt,
don't hesitate to save into a file, and check the content with
Ghostview
, or equivalent:
$ a2ps my_weird_file -Z -o mwf.ps $ gv mwf.ps
If your a2ps is correctly installed, you can use the display
fake-printer:
$ a2ps my_weird_file -Z -P display
If it is incorrect, ask for help around you.
a2ps complains that my file is binary though it is not.
There are several reasons that can cause a2ps to consider a file is binary:
--print-anyway
.
file(1)
said the type of the file is data
, in
which case a2ps prefers not to print the file. Then you can either:
-Eplain
;
--print-anyway
;
sheets.map
:
binary: <data*>
~/.a2ps/sheets.map
a rule that overrides that
of the system's sheets.map
:
# Load the system's sheets.map include(/usr/local/share/a2ps/sheets/sheets.map) # Override the rule for files with type `data' according to file(1) plain: <data*>
But this is not very good, since then this rule is always the first
tested, which means that any file with type data
according to
file(1)
will be printed in plain
style, even if the file
is called foo.c
.
sheets.map
, such as
# file(1) says it's data, but it's pure text plain: /*.txx/
a2ps does not seem to honor--font-size
(or--lines-per-page
, or--chars-per-line
).
This is probably because you used -1
..-9
after the
--font-size
. This is wrong, because the options
-1
..-9
set the font size (so that there are 80 characters
per lines), and many other things (See Page Options, option
--font-size
).
Hence a2ps --font-size=12km -4
is exactly the same thing as
a2ps -4
, but is different from a2ps -4 --font-size=12km
.
Note that the `pure' options (no side-effects) to specify the number of
virtual pages are --columns
and --rows
.
A mini how-to on a2ps.
The option --margin[=size]
is meant for this. See
Sheet Options.
stdin
?-
as file name. Automatic style selection is of course much
weaker: without the file name, a2ps can only get file(1)
's
opinion (see Style Sheet Files). In general it means most
delegations are safe, but there will probably be no pretty-printing.
You
can supply a name to the standard input
(--stdin=name
) with which it could guess the language.
See Designing PostScript Prologues, for details. Make sure that all the information a2ps needs is available (see Font Files).
-b
?By the past, a2ps had an option -b
with which the fonts were
bold. Since now the fonts are defined by prologues (see Designing PostScript Prologues) this option no longer makes sense. A replacement
prologue is provided: bold
. To use it, give the option
--prologue=bold
.
lpr
How can I tella2ps
to asklpr
no to print the banner?How can I pass specific options to
lp
?
If your Printer:
fields in the configuration files were properly
filled (see Your Printers), you can use the variable
lp.options
to pass options to lpr
(or lp
, depending
on your environment):
a2ps -Dlp.options="-h -s" -P printer
You can also define lp.options
once for all, See Defining Variables.
Finally, you can use Printer:
several times to reach a printer
with different lpr
options.
I use a2ps at work and wish to use it at home, but my printer is not PostScript. How can I do?
Ghostscript
might be the tool you need (see Glossary). It
support conversion to many different non PostScript printers.
Here are some tips on how to use a non PostScript printer. If somebody feels like writing a more precise documentation, she really is welcome.
Please refer to the Ghostscript
documentation for a precise
description of the tuning you need.
Basically, the first step you need is to achieve to call
Ghostscript
in a pipe chain. In other words, try to find out the
right arguments Ghostscript
needs in order to print with a
command like this:
$ cat file.ps | gs more arguments
In general it is the same command as for calling Ghostscript
with
a filename, except that the file name to use is -
:
$ cat file.ps \ | gs -q -dNOPAUSE -sDEVICE=deskjet -sOutputFile=- - -c quit\ | lp -dprinter-name
Once it works, it is then easy to settle the right Printer:
line
in your configuration file (see Your Printers). For instance:
Printer: djet \ | gs -q -dNOPAUSE -sDEVICE=deskjet -sOutputFile=- - -c quit\ | lp -d djetChristian Mondrup uses a2ps under Windows with a non PostScript printer. He uses:
DefaultPrinter: | //c/gstools/gs5.10/Gswin32c.exe \ -Ic:\gstools\gs5.10;c:\gstools\gs5.10\fonts \ -sDEVICE=ljet4 -sPAPERSIZE=a4 -dNOPAUSE -r300 -dSAFER \ -sOutputFile="\\spool\HP LaserJet 5L (PCL)" \ -q - -c quit
By the past, when I printed a man page with a2ps, it used underlines, but now it uses italics. I want underlines back!
Use a2ps --pro=ul
.
Wondering something?
The famous Y2K6 problem...
Yes, a2ps is Y2K compliant... provided that you have either a version
more recent than 4.10.3. The expansions of the following escapes were
broken (giving 100
instead of 00
): %D
, %W
,
$D
, $W
.
Nevertheless, please note that if you required a two digit year, expect
to have Jan 1st, 00
someday. You are responsible of the
format you want for the date: See Escapes.
The options of this a2ps are not the same as in the previous versions.
True. But the old scheme (up to version 4.6.1) prevented us from offering more options. We had to drop it, and to fully redesign the options handling.
Since that profound change, we try to change as little as possible between versions. Nevertheless, as the time passes, we discover that some never used options should be renamed, or used for something else. In these cases, compatibility code is left for a long time.
Anywhere you put options but the command line (e.g., in a2ps configuration files or in shell scripts), avoid using short options, since short options are much more likely to be changed (there are not so many, so it is a precious resource). Since there are as many long options as one wants, we can leave compatibility code with the long options.
yacc
and suchThere are several reasons why we decided not to use grammars to parse the files. Firstly it would have made the design of the style sheets much more tricky, and today a2ps would know only 4 or 5 languages.
Secondly, it limits the number of persons who could build a style sheet.
Thirdly, we did not feel the need for such a powerful tool: handling the keywords and the sequences is just what the users expect.
Fourthly, any extension of a2ps would have required to recompile.
And last but not least, using a parser requires that the sources are syntactic bug free, which is too strong a requirement.
Nevertheless, PreScript
gives the possibility to have on the one
hand a syntactic parser which would produce PreScript
code, and
on the other hand, a2ps, which would make it PostScript. This schema
seems to us a good compromise. If it is still not enough for you, you
can use the library.
This section settles some terms used through out this document, and provides the definitions of some terms you probably want to know about.
psnup
, psselect
etc.) can post process
PostScript files.
The DSC are edited by Adobe. A document which respects them is said to
be DSC conformant.
a2ps follows all the DSC.
To know more about encodings, see What is an Encoding.
Ghostscript
gs
Ghostscript
,
gs
for short, is a full PostScript interpreter running under many
various systems (Unices, MS-DOS, Mac etc.). It comes with a large set
of output formats allowing many different applications:
Ghostview
or gv
...).
ghostscript
, you may print PostScript files on non PostScript
printers.
ISO Latin 1
is a name.
a2ps never uses a name, but the key.
A key is the identifier of a unique object. This is information
that a2ps processes, hence, whenever you need to specify an object to
a2ps, use the key, not its name. For instance latin1
is the
unique identifier of the ISO Latin 1
encoding.
HTML
, PostScript,
LaTeX, roff
and others are such languages. A file written in
those languages is not made to be read as is by a human, but to be
transformed (or compiled) into a readable form.
HTML
, or roff
, but as TeX and LaTeX, it is
truly a programming language which main purpose is to draw (on sheets).
Most programs are a list of instructions that describes lines, shades of
gray, or text to draw on a page. This is the language that most
printers understand.
Note that the fact that PostScript is a programming language is
responsible of both its success and its failure. It is a big win for
the PostScript programmer who can easily implement a lot of nice visual
effects. It is a big loss because the page descriptions can have an
arbitrary complexity, hence rendering can be really slow (remember the
first Laser you had, or even Ghostscript
. PDF
has been
invented by Adobe to remedy these problems).
PostScript is a trademark of Adobe Systems Incorporated.
PostScript has pretended to be a device independent page description
language, and the PPD files are here to prove that
device independence was a failure.
psutils
psutils
to run correctly, the PostScript files must be DSC
conformant, and the bad news is that many PostScript drivers produce
files which are not. For some common cases (e.g., Micro$oft tools),
Angus Duggan included in the package some tools (named fix...ps
)
to fix typical problems. fixps
is a collection of recipes on
when to run what fix
tool.
Here are some words on a2ps and its history.
The initial version was a shell program written by Evan Kirshenbaum. It was very slow and contained many bugs.
A new version was written in C
by Miguel Santana to improve execution speed and portability. Many new
features and improvements have been added since this first version.
Many contributions (changes, fixes, ideas) were done by a2ps users in
order to improve it.
From the latest version from Miguel Santana (4.3), Emmanuel Briot
implemented bold faces for keywords in Ada
, C
and
C++
.
From that version, Akim Demaille generalized the pretty-printing capabilities, implemented more languages support, and other features.
Patrick Andries, from Alis Technologies inc. and Roman Czyborra (see his home page), provided us with important information on encodings. We strongly recommend that you go and read these pages: there is a lot to learn.
Juliusz Chroboczek worked a lot on the integration of the products of
Ogonkify (such as Latin 2 etc. fonts) in a2ps. Without his help, and
the time is devoted to both a2ps and ogonkify
, many non
west-European people would still be unable to print easily texts written
in their mother tongue.
Denis Girou brought a constant and valuable support through out the
genesis of pretty-printing a2ps. His comments on both the program
and the documentation are the origin of many pleasant features (such as
--prologue
).
Alexander Mai provided us with invaluable help in the development. He spotted several times subtle bugs in a2ps and the contributions, he keeps a vigilant eye on portability issues, he checks and improves the style sheets, and he maintains a port of a2ps for OS/2.
Graham Jenkins, with an extraordinary regularity, tortures a2ps on
weird systems that nobody ever heard of :)
. Graham is usually
the ultimate test: if he says I can release a2ps, I rest reassured
that, yes, this time it will compile! If a2ps works today
on your system, you should thank Graham too!
Of course this list is not up to date, and never will. We would like to thank everybody that helped us, talked to us, and even criticized us with the intention to help us to improve a2ps. Of course it doesn't sound right, yes it sounds a little childish, but we can tell you: we would never have the strength and the faith of building and maintaining a2ps without the support of all these guys.
While a2ps is finally just a couple of bits on a hard disk, to us it is an adventure we live with other humans, and, boy, that's a darn good pleasure!
Some people worked on the translation of a2ps:
Ogonkify
(see top).
The subroutines and source code in the a2ps package are "free"; this means that everyone is free to use them and free to redistribute them on a free basis. The a2ps-related programs are not in the public domain; they are copyrighted and there are restrictions on their distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of these programs that they might get from you.
Specifically, we want to make sure that you have the right to give away copies of the programs that relate to a2ps, that you receive source code or else can get it if you want it, that you can change these programs or use pieces of them in new free programs, and that you know you can do these things.
To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the a2ps-related code, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the programs that relate to a2ps. If these programs are modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.
The precise conditions of the licenses for the programs currently being distributed that relate to a2ps are found in the General Public Licenses that accompany them.
%!
: Your PostScript magic number
.a2ps
: Configuration Files
:
: Your Shortcuts
a2ps-site.cfg
: Configuration Files
a2ps.cfg
: Configuration Files
A2PS_CONFIG
: Configuration Files
A2PS_VERBOSITY
: Global Options
a2psrc
: Configuration Files
AppendLibraryPath:
: Your Library Path
C-char
: Declaring sequences
C-string
: Declaring sequences
DefaultPrinter:
: Your Printers
Delegation:
: Defining a Delegation
display
: Special Printers
elm
: Interfacing With a Mailer
file
: Special Printers
Ghostscript
: Glossary
gs
: Glossary
Include:
: Including Configuration Files
libpaper
: Sheet Options
LibraryPath:
: Your Library Path
make_fonts_map.sh
: Adding More Font Support
Medium:
: Your Media
Options:
: Your Default Options
OutputFirstLine:
: Your PostScript magic number
PageLabelFormat:
: Your Page Labels
paperconf
: Sheet Options
pine
: Interfacing With a Mailer
PrependLibraryPath:
: Your Library Path
PreScript
: PreScript
Printer:
: Your Printers
psutils
: Glossary
setpagedevice
: PostScript Options
sheets.map
: Name and key, Style Sheet Files
statusdict
: PostScript Options
TemporaryDirectory:
: Your Internal Details
UnknownPrinter:
: Your Printers
UserOption:
: Your Shortcuts
Variable:
: Defining Variables
void
: Special Printers
A
classical Unix trick to make the difference between the option
-2
, and the file -2
is to type ./-2
.
That is to say, there are no PostScript printers that don't understand these files.
Current a2ps
only handles PostScript output, i.e. out=ps
Because hiding its use into a2ps
just makes
it even more difficult to the users to know why it failed. Let them use
it by hand.
Many people seem to ignore that you can insert several sheets in the manual feed tray. Try at least once, it will save you from hours spent feeding page per page by hand!
Year 2000.