groff
[Top][All Lists]
Advanced

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

Re: Pop quiz: How do YOU .do?


From: John Gardner
Subject: Re: Pop quiz: How do YOU .do?
Date: Tue, 14 Apr 2020 20:28:52 +1000

Wouldn't it be cool if we could just

.nr _C \n(.C
.
.\" Rename the `cp` request to something inane
.rn cp ^GC  \" Here, ^G means U+0007
.
.de cp
.   ie        '+1'\\$1' .nr _C \\n(_C+1  \" +1: Begin new level
.   el \{ .ie '-1'\\$1' .nr _C \\n(_C-1  \" -1: End current level
.   el                  .nr _C \\$1      \" Default behaviour
.   \}
.
.   \" Keep value of `_C` register >= 0
.   if \\n(_C<0 .nr _C 0
.
.   ie \\n(_C .^GC 1
.   el        .^GC 0
..


And then just


.de1 MAGIC_GROFF_SHIT
.   cp +1
.   \" … do Groff stuff
.   cp -1
..
\n(.C   \" 1
.do MAGIC_GROFF_SHIT
\n(.C   \" 1


Instead of

.de1 MAGIC_GROFF_SHIT
.   cp +1
.   \" … do Groff stuff
.   cp -1
..
\n(.C   \" 1
.do MAGIC_GROFF_SHIT
\n(.C   \" 0    \[emoji-sad-face]



On Tue, 14 Apr 2020 at 19:54, G. Branden Robinson <
address@hidden> wrote:

> How well do you know groff's .do request?  Put it to the test!
>
> I found the existing man page documentation much too light and a certain
> paragraph in the Texinfo manual confounding.
>
> But I know there are people reading this list who are highly
> experienced, or simply more clever than I am.
>
> Pretend you are groff, running without the -C flag, writing to an
> nroff device, and you are given the region between the SNIPs below as
> input.
>
> What will your output be?
>
> A plain-text hint is attached, as well as the solution, base64-encoded.
>
> ---SNIP---
> .pl 1v
> .de mac1
> FOO
> ..
> .de1 mac2
> groff
> .mac1
> ..
> .de mac3
> compatibility
> .mac1
> ..
> .de ma
> \\$1
> ..
> .cp 1
> .do mac1
> .do mac2
> .do mac3
> .do ma \[ti]
> ---SNIP---
>
> Regards,
> Branden
>


reply via email to

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