Troff - Preprocessors

Preprocessors

As troff evolved, since there are several things which cannot be done easily in troff, several preprocessors were developed. These programs transform certain parts of a document into troff input, fitting naturally into the use of "pipelines" in Unix — sending the output of one program as the input to another (see pipes and filters). Typically, each preprocessor translates only sections of the input file that are specially marked, passing the rest of the file through unchanged. The embedded preprocessing instructions are written in a simple application-specific programming language, which provides a high degree of power and flexibility.

  • eqn preprocessor allows mathematical formulae to be specified in simple and intuitive manner.
  • tbl is a preprocessor for formatting tables.
  • refer (and the similar program bib) processes citations in a document according to a bibliographic database.

Three preprocessors provide troff with drawing capabilities by defining a domain-specific language for describing the picture.

  • pic is a procedural programming language providing various drawing functions like circle and box.
  • ideal allows the drawing of pictures declaratively, deriving the picture by solving a system of simultaneous equations based on vectors and transformations described by its input.
  • grn describes the pictures through graphical elements drawn at absolute coordinates, based on the gremlin file format defined by an early graphics workstation.

Yet more preprocessors allow the drawing of more complex pictures by generating output for pic.

  • grap draws charts, like scatter plots and histograms.
  • chem draws chemical structure diagrams.
  • dformat draws record-based data structures.

Read more about this topic:  Troff