5 Using the alternative highlighter pdlsthighlight

Notice: The following part of this section is typeset in two-column mode in the original form of this document. Refer to the PDF or Postscript formats of this document in order to see the original version.

In addition to the default highlighter pdhighlight ProgDoc comes now with an additional highlighter called pdlsthighlight which is in fact a wrapper for the listings environment of Carsten Heinz (see [listings]).

Notice: The following listing was highlighted using pdlsthighlight as highlighter, which is not supported by LaTeX2HTML. That's why the HTML version of the listing will be printed in plain text. Refer to the PDF or Postscript formats of this document in order to see the original version.

Listing 3: A short Python example (Referenced in Listing 2)
def ggd(a, b):
  if a < b: a,b = b,a
  while a%b != 0:
    a,b = b,a%b
  return b

To use this highlighter the listings.sty package has to be installed and manually loaded into the document with \usepackage{ listings}. The Listings 2 to 4 are typeset using pdlsthighlight with the following options: [linenr, listing, wrap=40, fontname=blg, highlighter= 'pdlsthighlight', type=Python].

pdlsthighlight also works in both, single and two-column mode, however it doesn't support the ``Listing x: ... (continued)'' captions at all. The benefits of the new highlighter are the many supported language for which the listings package performs syntax highlighting. One of the main drawbacks is the fact that you can not produce an HTML version of the document because LATEX2HTML doesn't support the package.

Notice furthermore that you have to set the type option of the \sourceinput command to a value recognized by the listings environment if you use pdlsthighlight as highlighter (e.g. type=C++ instead of type=cpp). Refer to [listings] for a complete list of supported languages.

Notice: The following listing was highlighted using pdlsthighlight as highlighter, which is not supported by LaTeX2HTML. That's why the HTML version of the listing will be printed in plain text. Refer to the PDF or Postscript formats of this document in order to see the original version.

Listing 4: A short Python example (Referenced in Listing 2)
def quicksort(arr):
  if len(arr) <= 1: return arr
  m = arr[0]
  return quicksort(filter(lambda i,j=m: ij, arr))

In this context it may also be necessary to use the comment option to specify the comment characters of a language not known to pdweave.

Volker Simonis 2003-03-05