[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 10/10: groff(7): Revise introductory sections.

From: G. Branden Robinson
Subject: [groff] 10/10: groff(7): Revise introductory sections.
Date: Wed, 10 Nov 2021 09:23:46 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 341255963a8ad98df7c3572f6c75f8fce0591b40
Author: G. Branden Robinson <>
AuthorDate: Thu Nov 11 00:35:22 2021 +1100

    groff(7): Revise introductory sections.
    * Rewrite introductory paragraphs.
    * Add "Input format" section.
    * Rewrite "groff elements" section.
 man/ | 451 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 278 insertions(+), 173 deletions(-)

diff --git a/man/ b/man/
index 41f111c..7e3d9df 100644
--- a/man/
+++ b/man/
@@ -240,252 +240,323 @@ for a survey and the background of
 .I roff
-.I groff
-also refers to GNU
-.I roff
-system's front end,
-.MR groff @MAN1EXT@ .
-This document provides only short descriptions of roff language
+This document is intended as a reference.
-.IR "Groff: The GNU Implementation of troff" ,
-by Trent A.\& Fisher and Werner Lemberg,
-is the primary
+The primary
 .I groff
-and is written in Texinfo.
+.IR "Groff: The GNU Implementation of troff" ,
+by Trent A.\& Fisher and Werner Lemberg,
+is a better resource for learners,
+containing many examples and much discussion.
-You can browse it interactively with \[lq]info groff\[rq].
+It is written in Texinfo;
+you can browse it interactively with \[lq]info groff\[rq].
+Additional formats,
+including plain text,
+and PDF,
+may be available in
+.IR \%@DOCDIR@ .
-Historically, the
-.I roff language
-was called
-.IR troff .
-.I groff
-is compatible with the classical system and provides proper
-So in GNU, the terms
-.IR roff ,
-.IR troff ,
-.I groff language
-could be used as synonyms.
-.I troff
-slightly tends to refer more to the classical aspects, whereas
 .I groff
-emphasizes the GNU extensions, and
+is a member of a family of related
 .I roff
-is the general term for the language.
+languages that share many traits.
+We use \[lq]roff\[rq] to denote features that are universal,
+or nearly so,
+among implementations of this family.
-The general syntax for writing groff documents is relatively easy, but
-writing extensions to the roff language can be a bit harder.
+We apply the term \[lq]groff\[rq] to the language documented here,
+the GNU implementation of the overall system,
+and the command of that name.
-The roff language is line-oriented.
+.IR troff , \" GNU
+installed on this system as
+.MR @g@troff @MAN1EXT@ ,
+is the
+.I formatter:
+a program that reads device and font descriptions
+.MR groff_font @MAN5EXT@ ),
+interprets the
+.I groff
+language expressed in text input files,
+and translates that input into a device-independent output format
+.MR groff_out @MAN5EXT@ )
+that is usually then post-processed by an output driver to produce
+or terminal output.
-There are only two kinds of lines, control lines and text lines.
-The control lines start with a control character, by default a period
-.dquoted_char .
-or a single quote
-.dquoted_char \[aq] ;
-all other lines are text lines.
+.\" ====================================================================
+.SH "Input format"
+.\" ====================================================================
+.I roff
+input files contain text interspersed with instructions to control the
-.B Control lines
-represent commands, optionally with arguments.
+Even in the absence of such instructions,
+.I \%@g@troff
+still processes its input in several ways,
+by filling,
+and adjusting it,
+and supplementing it with inter-sentence space.
-They have the following syntax.
-The leading control character can be followed by a command name;
-arguments, if any, are separated by spaces (but not tab characters)
-from the command name and among themselves, for example,
-.Text .command_name arg1 arg2
+Input to
+.I \%@g@troff
+must be in one of two character encodings it can recognize:
+IBM code page 1047 on EBCDIC systems,
+and ISO\~Latin-1 (8859-1) otherwise.
+Use of ISO\~646-1991:IRV (\[lq]US-ASCII\[rq]) or (equivalently) the
+\[lq]Basic Latin\[rq]
+subset of ISO\~10646 (\[lq]Unicode\[rq]) is recommended;
+.MR groff_char @MAN7EXT@ .
-For indentation, any number of space or tab characters can be inserted
-between the leading control character and the command name, but the
-control character must be on the first position of the line.
+.MR groff @MAN1EXT@
+and the
+.MR preconv @MAN1EXT@
+preprocessor can transform other encodings,
+including UTF-8,
+to satisfy
+.IR \%@g@troff 's
-.B Text lines
-represent the parts that is printed.
-They can be modified by escape sequences, which are recognized by a
-leading backslash
-.squoted_char \[rs] .
-These are in-line or even in-word formatting elements or functions.
-Some of these take arguments separated by single quotes
-.dquoted_char \[aq] ,
-others are regulated by a length encoding introduced by an open
-.squoted_char (
-or enclosed in brackets
-.squoted_char [
-.squoted_char ] .
+.I groff
+input is organized into lines separated by the Unix newline character
+(U+000A) and parsed character by character.
 .\" ====================================================================
 .SH "\f[I]groff\f[] elements"
 .\" ====================================================================
-The roff language elements add formatting information to a text file.
+Lines of input to any
+.I roff
+formatter can be classified as one of two types:
+control lines and text lines.
-The fundamental elements are predefined commands and variables that
-make roff a full-blown programming language.
+.I control line
+starts with the
+.I control character,
+a dot
+.RB (\[lq] .\& \[rq])
+or the
+.I no-break control character,
+a neutral apostrophe
+.RB (\[lq] \[aq] \[rq]).
+Either control character is followed by zero or more spaces or tabs
+and then an optional
+.I request,
+an instruction built in to the formatter.
+Some requests take one or more
+.I arguments,
+which follow on the same line,
+separated from the request name and each other only by spaces.
-There are two kinds of roff commands, possibly with arguments.
-.B Requests
-are written on a line of their own starting with a dot
-.squoted_char .\&
-or a
-.dquoted_char \[aq] ,
-.B Escape sequences
-are in-line functions and in-word formatting elements starting with a
-.squoted_char \[rs] .
+Any input line that is not a control line is a
+.I text line.
+See section \[lq]Line continuation\[rq] below for an exception to this
+Text lines generally become formatted output.
+To start a text line with the control or no-break control character,
+prefix the character with the
+.B \[rs]&
+escape sequence.
-The user can define her own formatting commands using the
-.request .de
+.I Escape sequences
+start with the
+.I escape character,
+a backslash
+.B \[rs],
+and are followed by at least one additional character.
-These commands are called
-.BR macros ,
-but they are used exactly like requests.
+They can appear anywhere in the input.
-Macro packages are pre-defined sets of macros written in the groff
-A user's possibilities to create escape sequences herself is very
-limited, only special characters can be mapped.
+With requests,
+the escape and control characters can be changed and,
+.I groff,
+the escape mechanism can be turned off and back on.
-The groff language provides several kinds of variables with
-different interfaces.
+.I Macros
+permit the extension or replacement of the request repertoire.
+Requests like
+.request .de
+(shown here with a leading control character to clarify its identity)
+can be invoked to define a macro,
+a user-directed abbreviation for a collection of input lines.
+Macros are called on control lines much as requests are invoked,
+albeit with occasional differences in argument handling.
+When a macro is called,
+its definition
+(or \[lq]body\[rq])
+.I interpolated,
+as if typed at its call site.
-There are pre-defined variables, but the user can define her own
-variables as well.
+Its contents are then parsed normally.
-.B String
-variables store character sequences.
+.I Strings
+store character sequences.
-They are set with the
+They are defined with the
 .request .ds
-request and retrieved by the
+request and interpolated with the
 .esc *
-escape sequences.
+escape sequence.
-Strings can have variables.
+Strings can be parameterized as macros can.
-.B Register
-variables can store numerical values, numbers with a scale unit, and
-occasionally string-like objects.
+.I Registers
+store numerical values.
 They are set with the
 .request .nr
-request and retrieved by the
+request or
+.esc R
+escape sequence and interpolated with the
 .esc n
-escape sequences.
-.B Environments
-allow the user to temporarily store global formatting parameters like
-line length, font size, etc.\& for later reuse.
+escape sequence.
-This is done by the
-.request .ev
+Some read-only predefined registers interpolate text.
-.B Fonts
-are identified either by a name or by an internal number.
+.I Fonts
+are identified either by a name or by a mounting position
+(a non-negative number).
-The current font is chosen by the
+A font is selected for glyph rendering by the
 .request .ft
 request or by the
 .esc f
-escape sequences.
+escape sequence.
+Four font styles are available on all devices.
-Each device has special fonts, but the following fonts are available
-for all devices.
 .B R
-is the standard font Roman.
+is \[lq]Roman\[rq]:
+upright text.
 .B B
-is its
-.B bold
+.BR bold ,
+an upright typeface with a heavier weight.
-.I italic
-font is called
 .B I
-and is available everywhere, but on text devices it is displayed as an
-underlined Roman font.
+.IR italic ,
+a face that is oblique on typesetter output devices and usually
+underlined instead on terminal devices.
+.B BI
+is \f[BI]bold-italic\f[]\,, \" indulging a bit of man(7) evil here
+combining both of the foregoing style variations.
+Typesetter devices typically offer one or more
+.I special
+fonts as well;
+they provide glyphs that are not available in the multiple styles of
+text fonts.
-For the graphical output devices, there exist constant-width pendants
-of these fonts,
-.BR CR ,
-.BR CI ,
+.I groff
+supports named
+.I colors
+for glyph rendering and drawing of geometric primitives.
+Stroke and fill colors are distinct;
+the stroke color is used for glyphs.
+Colors are defined with the
+.request .defcolor
+and selected with the
+.request .gcolor
+.request .fcolor
+requests or
+.esc m
-.BR CB .
-On text devices, all glyphs have a constant width anyway.
+.esc M
+escape sequences.
-.B Glyphs
+.I Glyphs
 are visual representation forms of
-.BR characters .
-In groff, the distinction between those two elements is not always
-obvious (and a full discussion is beyond the scope of this man page).
+.I characters.
-A first approximation is that glyphs have a specific size and
-colour and are taken from a specific font; they can't be modified any
-more \[en] characters are the input, and glyphs are the output.
+.I groff,
+the distinction between those two elements is not always obvious
+(and a full discussion is beyond our scope).
-As soon as an output line has been generated, it no longer contains
-characters but glyphs.
+To roughly characterize,
+\[lq]A\[rq] is a character when we consider it in the abstract:
+to make it a glyph,
+we must select a typeface with which to render it,
+and determine its type size and color.
-In this man page, we use either \[oq]glyph\[cq] or
-\[oq]character\[cq], whatever is more appropriate.
+The formatting process turns input characters into output glyphs.
 A few characters commonly seen on keyboards are treated
 specially by
 .I roff
-languages and may not look correct in output;
+languages and may not look correct in output if used unthinkingly;
 they are
 the (double) quotation mark
 .RB ( \[dq] ),
-the apostrophe
+the neutral apostrophe
 .RB ( \[aq] ),
 the minus sign
 .RB ( \- ),
@@ -498,34 +569,68 @@ the grave accent
 and the tilde
 .RB ( \[ti] ).
-All are available if required;
+All are available via
+.I special character
+escape sequences,
+along with numerous other symbols;
 .MR groff_char @MAN7EXT@ .
-Moreover, there are some advanced roff elements.
+A further few language elements arise as page layouts become more
+sophisticated and demanding.
-.B diversion
-stores (formatted) information into a macro for later usage.
-.MR groff_tmac @MAN5EXT@
-for more details.
+.I Environments
+collect formatting parameters like line length and typeface.
-.B trap
-is a positional condition like a certain number of lines from page top
-or in a diversion or in the input.
+.I diversion
+stores formatted output for later use.
-Some action can be prescribed to be run automatically when the
-condition is met.
+.I trap
+is a condition on the input or output,
+tested automatically by the formatter,
+that is associated with a macro,
+causing it to be called when that condition is fulfilled.
+.\" TODO: Move this paragraph to our Texinfo manual and roff(7).
-More detailed information and examples can be found in the
-.I groff
-Texinfo manual.
+Footnote support often exercises all three of the foregoing features.
+A simple implementation might work as follows.
+A pair of macros is defined:
+one starts a footnote and the other ends it.
+The author calls the first macro where a footnote marker is desired.
+The macro establishes a diversion so that the footnote text is collected
+at the place in the body text where its corresponding marker appears.
+An environment is created for the footnote so that it is set at a
+smaller typeface.
+The footnote text is formatted in the diversion using that environment,
+but it does not yet appear in the output.
+The document author calls the footnote end macro,
+which returns to the previous environment and ends the diversion.
+after much more body text in the document,
+a trap,
+set a small distance above the page bottom,
+is sprung.
+The macro called by the trap draws a line across the page and emits the
+stored diversion.
+the footnote is rendered.
 .\" ====================================================================
@@ -708,8 +813,8 @@ There is a sophisticated interface for handling tab 
 .SH "Line continuation"
 .\" ====================================================================
-.I groff
-distinguishes input and output line continuation.
+.I roff
+languages distinguish input and output line continuation.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]