On Wed Jan 1, 2025 at 10:38 AM CET, Ihor Radchenko wrote:
> >> Also, what if we leave \fC and add \f[CR]/.EX on top?
> >> AFAIU, the worst case scenario for \fC is that it does nothing. By
> >> leaving it there, we thus retain old working exports working while also
> >> adding appropriate format when \f[CR] is supported.
> >
> > The \f escape sets current font. \fP restores previous font.
> > What this means is that doing \fC\f[CR]Lorem\fP:
> >  (1) sets the text Lorem in Courier if font name C or CR exists
> >  (2) restores previous font if neither font C nor CR exists
> >  (3) sets font to Courier if both font name C and CR exist
>
> What about \fC\f[CR]Lorem\fP\fP?

(1) if both C and CR exist, sets Lorem in Courier
(2) if only C or CR exists, sets font to Courier
(3) if neither exists, does nothing

To understand #2, let's assume that C is defined and CR is not. Then:
  \fC -> set font to C
  \f[CR] -> ignored
  \fP -> restore previous font, set previous font to C
  \fP -> restore previous font (back to C)

It's important to understand that troff commands don't really use
nesting or a stack as one might be used to from HTML and similar
markup languages. That's why it's also not possible to e.g. nest
bold and italic like this:
  Normal \fBbold \fIbold-italic\fP bold\fP normal

...which actually gives you:
  Normal bold italic bold italic

One has to do one of these instead:
  Normal \fBbold \f[BI]bold-italic\fP bold\fR normal
  Normal \fBbold \f[BI]bold-italic\fB bold\fR normal
  Normal \fBbold\fP \f[BI]bold-italic\fP \fBbold\fP normal

> >> Do I understand correctly that blank line is sometimes interpreted as
> >> vertical spacing and sometimes ignored?
> >
> > A blank input line is equivalent to .sp unless the .blm request was called
> > to change this behavior. .blm is groff's invention (see groff_diff(7)).
>
> Then maybe we can put .sp explicitly instead of a blank line.
> In our code, we add blank after blocks (or displays) of code. Extra
> vertical space after seems to be reasonable.

They are equivalent as far as troff formatters are concerned. The question
is whether they are equivalent to the various other programs that attempt
to interpret man source code directly. So I guess this depends on whether
you're targetting only troff (+ BSD mandoc) or not. Branden will likely
tell you more about this topic.

~ onf

Reply via email to