G. Branden Robinson <[email protected]> wrote:

> Another thing that might help is to have the source document record
> where the right margin is by having the formatter compute it and then
> issue it as a "trout" comment for collection and interpretation by your
> filter.  This could be more reliable than doing it yourself in AWK, and
> almost certainly preferable to doing arithmetic in sed(1).[A]
> 
> Sketch:
> 
> $ printf '.po 1i\n.in 2i\n.ll 3i\n.nr right-margin 
> \\n[.o]+\\n[.i]+\\n[.l]\n\\!# right-margin=\\n[right-margin]\n' \
>  | groff -Z
> x T ps
> x res 72000 1 1
> x init
> p1
> # right-margin=432000
> x trailer
> V792000
> x stop

I think `\\n[.o]+\\n[.l]` would be sufficient to calculate the right margin.
The `.in` request indents relative to the page offset, so it could be safely
ignored outside a corner case like this, where the `.po` and `.ll` requests
have not been defined yet. But if a negative `.in` request were to push
text *into* the left margin, it would be best to not mess with that line at all.

>> [2] As I mentioned earlier, groff has a 1/1000 pt resolution,
> 
> On the "ps" and "pdf" devices, yet.  Others vary.

Good point (not to mention `res 1200` for devlj4). My first thought was that
people would only want hanging punctuation on PS/PDF output, but I could
see people wanting it for their printers (or DVI) as well.

So if there is neither a command-line option nor a trout comment to tell
the vaporware `hangpunc` command where the right margin is, it could
either gripe and quit or gripe and attempt to calculate the right margin,
then quit and suggest using the calculated value in the next attempt.

I hope to have a chance to work on this next week, once Daughter Dearest
is finished with school stuff (she’s a teacher) and I won’t be watching her
kids all day (most days, at least).

— Larry

Reply via email to