groff
[Top][All Lists]
Advanced

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

Re: Is there a Groff showcase?


From: Larry McVoy
Subject: Re: Is there a Groff showcase?
Date: Thu, 14 Dec 2023 17:44:56 -0800
User-agent: Mutt/1.5.24 (2015-08-30)

On Fri, Dec 15, 2023 at 01:28:56AM +0000, Mike wrote:
> > Almost all my exams (being a science teacher) are created using
> Groff.
> 
> That sounds really interesting. If it isn't confidential, I'd love to
> see a copy of your exam paper to see how it was made and how you create
> two versions in the same document.

I can give you the source to the commercial license for a product we did.
I actually got the lawyers at Fenwick & West to work on this in the troff
source.  Once they got what I was doing they were ecstatic, they clearly
saw the value in one document generating multiple documents.  Their comment
was "Word wishes it could do this".

Here's the intro at the top of the -ms doc:

.ig
                ****** README FIRST ******

Notes for people unfamiliar with this file format:

Line breaks are very important, if you work on this work on it with an
editor that does hard line breaks, don't use soft (automatic) line breaks.

Comments may be entered with a leading .\" or in a block delimited with
a starting ".ig" (for ignore) and an ending ".." on a line by itself.

Markup requests are present in the document, they are the funky looking
things which start a line with a period like ".HH".

Since the section numbers are automatically generate with the .HH macro
we manually inserted .\" [1] above each .HH so you could see which section
you are in, i.e., [1] above the first one, [2] above the next, and so on.
Makes it slightly easier to go from the formatted text to the source.

This document is actually several documents.  It conditionally produces
output based on the EULA variable which is currently set to one of
0 (Academic), 1 (Basic), 2 (Pro), or 3 (Enterprise).  We'll likely
shift that up when we fold the Free license into this one.  You can do
conditional exclusion or inclusion of the text based on the EULA variable
like so (indented for clarity, it may not be indented in real use):

        .if \n[EULA]=1 \{\
        I am the basic license agreement
        .\}
        .if \n[EULA]<=1 \{\
        I am either the basic or the academic license agreement
        .\}
        .if \n[EULA]>1 \{\
        I am either the pro or the enterprise license
        .\}

You can do a conditional on two different EULAs like so:

        .if ((\n[EULA]=2) : (\n[EULA]=4)) \{\
        I am either EULA2 or EULA4
        .\}

You negate an expression with "!"

        .if !\n[EULA]=4 \{\
        All eulas except 4.
        .\}

You can do if/else in this oh-so-obvious way:

        .ie \n[EULA]=4  text for EULA4
        .el             text for all other cases

And finally, the \{ stuff is not needed if you are doing a short line.
        
        .if \n[EULA]=4 Use this text for EULA4.

Given that we have two classes of licenses being generated here, EULA and
MLA, we are evolving a bit.  EULA 0..3 are EULAs, 4 is Intel, 5 is Cisco.
But for each EULA we define a string, EULA, and for each MLA we define a
string, MLA.  We don't use the contents of the string, just the fact that
it exists.  We also define INTEL for Intel and CISCO for Cisco.  

This lets me do MLA specific stuff that is not Intel or Cisco specific like so

        .if dMLA

and we can do INTEL specific stuff like so

        .if dINTEL

Etc.

Notes to reviewers/lawyers/whatever are typically done with "XXX"
markups in comments, search for those for hints on places which need work.

Thank you for putting up with this weird format, it helps us.
..
.if !rEULA .ab No EULA defined
.if \n[EULA]=0 \{\
.       ds type Academic End User
.       ds TYPE ACADEMIC END USER
.       ds EULA Academic
.\}
.if \n[EULA]=1 \{\
.       ds type Essentials End User
.ds TYPE ESSENTIALS END USER
.       ds EULA Essentials
.\}
.if \n[EULA]=2 \{\
.       ds type Premier End User
.       ds TYPE PREMIER END USER
.       ds EULA Premier
.\}
.if \n[EULA]=3 \{\
.       ds type Enterprise End User
.       ds TYPE ENTERPRISE END USER
.       ds EULA Enterprise
.\}
.if \n[EULA]=4 \{\
.       ds type / Intel Master
.       ds TYPE / INTEL MASTER
.       ds MLA Intel
.       ds INTEL true
.\}
.if \n[EULA]=5 \{\
.       ds type / Cisco Master
.       ds TYPE / CISCO MASTER
.       ds MLA Cisco
.       ds CISCO true
.\}



reply via email to

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