A version of fmt for troff files
Last-Updated: 2023-05-17
Sources
The different flavours of fmt
fmt is a simple program aimed at formatting text according to certain rules, mainly respecting an optimal width (measured in number of characters). As a UNIX utility, fmt was rewritten many times with different versions having different features. The main fmt versions are:
- the GNU version which is not intended to be used with *roff files for it reformat lines starting with a dot or an apostrophe;
- the BSD version, written with *roff compatibility features.
The version presented here (roquesor/fmtroff.c) was written by Walter Alejandro Iglesias for his own uses, which are formatting his novels typeset with groff (2023-02/msg00081).
This program:
- does not format lines beginning with a period or an apostrophe;
- always collapses consecutives spaces or tabs;
- breaks sentences with a new line character with option '-t';
- considers .?! and … as end of sentence characters and other Spanish specific symbols;
- is able to recognize initials and some abbreviations followed by a period and does not add spaces − or break the line with option '-t';
- copies the first line indentation of a paragraph as is, including tabs, when indenting a whole paragraph with option '-p'.
As such it is much more interesting to use this version of fmt instead of the GNU or BSD version when one needs to format a *roff file.
Mirror
The source file for Mr. Iglesias' fmt program is mirrored here:
← Go back