groff
[Top][All Lists]
Advanced

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

Re: [Groff] Request "cf"


From: Werner LEMBERG
Subject: Re: [Groff] Request "cf"
Date: Sun, 02 Mar 2008 11:28:21 +0100 (CET)

> > You say that you've found a solution using `.trf' -- please post
> > it here.
> 
> I haven't, you did. You taught me about this in bits an' pieces a
> year or so ago: [...]

Uuh, how embarassing :-)

Doing some debugging, I've found out that .trf does the job right: It
doesn't handle the escape character specially.  It's rather the
re-reading of the data as a string which causes the problem.

Here's another, more sophisticated try, cleverly mixing macros and
diversions.


======================================================================


.\" macro: ps-file-insert <file> [<before>] [<after>]
.\"
.\"
.\" file:   File name to be inserted literally into the PS output
.\"         stream.
.\" before: Name of a macro whose contents is inserted right before
.\"         <file>.
.\" after:  Name of a macro whose contents is inserted immediately
.\"         after <file>.
.
.de pfi-end
..
.
.de ps-file-insert
.  ie '\\$2'' \
.    ds pfi-before pfi-end\"
.  el \
.    ds pfi-before \\$2\"
.  ie '\\$3'' \
.    ds pfi-after pfi-end\"
.  el \
.    ds pfi-after \\$3\"
.
.  de pfi-buffer pfi-end
     ps: exec
     \\*[\\*[pfi-before]]
.  pfi-end
.
.  br
.  de pfi-aux pfi-end
.    da pfi-buffer
.      trf \\$1
.    da
.  pfi-end
.
.  pfi-aux
.
.  am pfi-buffer pfi-end
     \\*[\\*[pfi-after]]
.  pfi-end
.
.  devicem pfi-buffer
..
.
.
.de before
  aaa
..
.
.de after
  bbb
..
.
.ps-file-insert foo1 before after
.
.\" eof


======================================================================


Assuming that file `foo1' contains this:

  \a\b\c\d\e\$\x\y\z

I get this in the PS file (formatted):

  ...
  EBEGIN
  aaa
  \a\b\c\d\e\$\x\y\z
  bbb
  EEND
  ...

It seems that is what you want, right?  Please test it with a
real-case example.


    Werner




reply via email to

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