groff
[Top][All Lists]
Advanced

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

[Groff] conditionals


From: Larry McVoy
Subject: [Groff] conditionals
Date: Mon, 31 May 2010 21:16:28 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

Hi folks,

We, er, I, use groff to create multiple documents from one.  Here's our 
header (search for === to skip this):

.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
        .\}

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 !\n[EULA]=0 \{\
.if !\n[EULA]=1 \{\
.if !\n[EULA]=2 \{\
.if !\n[EULA]=3 \{\
.ab No EULA defined
.\}
.\}
.\}
.if \n[EULA]=0 .ds type Academic End User
.if \n[EULA]=1 .ds type Essentials End User
.if \n[EULA]=2 .ds type Premier End User
.if \n[EULA]=3 .ds type Enterprise End User
.if \n[EULA]=0 .ds TYPE ACADEMIC END USER
.if \n[EULA]=1 .ds TYPE ESSENTIALS END USER
.if \n[EULA]=2 .ds TYPE PREMIER END USER
.if \n[EULA]=3 .ds TYPE ENTERPRISE END USER

===

You may or may not be amused to know that we've sent the roff source to a 
lawyer at Fenwick and West and he was able to get it.  Pretty cool lawyer.
He got it to the point that he was stoked and was asking if there was any
way that Word could do this.  So far as I know, "no".

Anyway, the doc is full of 

        .if \n[EULA]=1 \{\

etc.

What I would oh-so-love to be able to do is 

        .if \n[EULA]=1 || \n[EULA]=3

I wandered through the groff docs and didn't see any way to do that.

A) Is there a way?
B) If not, if I send in a patch to do that would the team be open to 
   accepting it?

Thanks,

--lm



reply via email to

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