[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] multi-line macro arguments
From: |
Steffen Nurpmeso |
Subject: |
Re: [Groff] multi-line macro arguments |
Date: |
Wed, 27 Apr 2016 23:35:05 +0200 |
User-agent: |
s-nail v14.8.8-200-g511cecc |
(Ted Harding) <address@hidden> wrote:
|> ?ukasz Stelmach <address@hidden> wrote:
|>> I am developing a macro to print envelopes. Is it possible to pass a
|>> multi-line string (not necessarily defined with .ds) as a parameter
|>> for a macro?
|The basic idea is not to give a "multi-line string" as a single
|paramater, but to give the separate lines as separate arguments.
Or open a diversion, read in all lines, and then work with the
diversion. E.g., my letter template has something like
.RECEIVER
$TITLE
$NAME
$STREET
$CITY
.RECEIVER END
and the plain macro looks like (of course it's part of an,
heavily restricted,
.MACRO RECEIVER
. S:BOOLIFY \$1
. ie \n[S:#IS_BOOL] \{\
I.e., macro starting point
. vs \n(.su*\*[RECEIVER_LINE_SPACING_SCALE_FACTOR]
By default: RECEIVER_LINE_SPACING_SCALE_FACTOR 1.5
. nf
. de S:RECEIVER_TRAP EOT
. blm PARA
I use blank lines to cause paragraphs.
. ds S:RECEIVER_DIVERSION_HOOK
. sp 1v
\*[RECEIVER_PREHOOK]\c
By default: RECEIVER_PREHOOK \s[+1]
That's all very inflexible, but the way it's used will print the
postal code etc. in a larger font.
(It would need more hooks...)
.EOT
. di S:RECEIVER_DIVERSION
. blm S:RECEIVER_TRAP
. \}
. el \{\
Macro called with "END".
. if d S:RECEIVER_DIVERSION_HOOK \{\
\*[RECEIVER_POSTHOOK]\c
By default: RECEIVER_POSTHOOK \s[-1]
. rm S:RECEIVER_DIVERSION_HOOK
. \}
. di
. \" Calculate best position for address field and box out
. if (\n(dlu >= \n[#RECEIVER_WIDTH]u) \
Default: #RECEIVER_WIDTH 9c
. WARN \
"Receiver address is too width to fit in address window!"
. if (\n(dnu >= \n[#RECEIVER_HEIGHT]u) \{\
Default: #RECEIVER_HEIGHT 3.8c
. WARN \
"Receiver address does not fit in address window! Growing window!!"
. nr #RECEIVER_HEIGHT \n(dnu
. \}
. nr #1 (\n[#RECEIVER_HEIGHT]u-\n(dnu)/2u
. sp |(\n[#RECEIVER_START]u+\n(#1u
Default: #RECEIVER_START 4.15c
. rr #1
. S:RECEIVER_DIVERSION
. rm S:RECEIVER_DIVERSION
. rm S:RECEIVER_TRAP
. fi
. vs
. \}
..
The default dimensions are for C6 (for DIN A4).
The good thing about this approach is that quoting doesn't matter
at all.
--steffen