C# Style-Sheet


This article contains a C# style-sheet for the GNU a2ps print utility.  The style-sheet keywords, comments, preprocessor directives, and [] style attributes are pretty-printed in the typical a2ps fonts. The style-sheet is available under the terms of the GNU General Public License (GPL).

Use of the style-sheet should result in pretty-printed text such that:

Keywords that should be bold : abstract, as, break, case, catch, checked, const, continue, default, delegate, do, else, event, explicit, extern, finally, fixed, for, foreach, get, goto, if, implicit, in, internal, is, lock, amespace, new, operator, out, override, params, private, protected, public, readonly, ref, return, sealed, set, sizeof, stackalloc, static, switch, throw, try, typeof, unchecked, unsafe, using, virtual, volatile, while.

Keywords that should be italicized : base, bool, byte, char, decimal, double, enum, false, float, int, long, null, object, sbyte, short, string, this, true, uint, ulong, ushort, value, void.

Comments should be italicized.
Preprocessor directives should be italicized.
Attributes should be in a large-ish bold font.
Class/Interface/Struct names in declarations should be in a large-ish bold font.
The -> operator should look like a right arrow.
The <= and >= operators should be condensed to one character.

If you don't yet have GNU a2ps, this page, a2pshttp://gnuwin32.sourceforge.net/packages/a2ps.htm, is perhaps the most convenient location for downloading the Windows ports of a2ps and other supporting programs.  More information on a2ps can be found at http://www.inf.enst.fr/~demaille/a2ps/index.html or http://www.gnu.org/software/a2ps/a2ps.html.

To use the style-sheet, add the csharp.ssh file to the sheets subdirectory of the a2ps directory, and add these two lines to the sheets.map file to associate the csharp.ssh sheet with files using the .cs extension.

# C# files
csharp: /*.cs
 
To use it from the command line enter, a2ps -Epath/csharp.ssh ClassFile.cs, where path is the path to the csharp.ssh file.  Ghostscript and Ghostview can be used to preview the PostScript output.

The zip file contains the csharp.ssh style-sheet, a Sample.cs file used to test the style-sheet, and a Sample.ps output file from a2ps.  A Sample.jpg image of the output file is also included.  The code in Sample.cs does absolutetly nothing, and is only meant to cover all of the style-sheet elements. 

Up Next
    Ebook Download
    View all
    Learn
    View all