Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been using groff to make ps files for printing with the -man flag. If I want to convert anything else such as a header file or just the output from ls -l or other program the line breaks are ignored, producing a mess. How can I get groff to see and respect the line breaks in use in the shell?

This produces an output but the tabs are messed up:

groff -mom hexd.c > out.ps

But this messes with both tabs and line breaks:

cat hexd.c | groff -mom > out.ps

What I would really like is something like this:

man -t gdb | open -f -a preview

Which opens a perfect post script version of the man page in preview on max os. BTW. man -t is equivalent to:

groff  -Tps  -mandoc -c
share|improve this question

1 Answer 1

up vote 3 down vote accepted

groff is a typesetting language, and it's expecting input in its language, not plain text. You may be looking for something like enscript or a2ps (ascii-to-postscript).

share|improve this answer
    
It works for transferring man pages, which is also plain ascii AFAIK, it can also apart from ps also produce html. Anyway what lead to this was the following: "man -t gdb | open -f -a preview" Which opens the gdb man page in preview on mac os x. –  Fred Apr 13 '10 at 20:24
    
This is from the groff man page: "DESCRIPTION This document describes the groff program, the main front-end for the groff document formatting system." –  Fred Apr 13 '10 at 20:29
3  
The groff source for manpages is not "plain" text. It's a markup language. If you feed groff something that's not in its markup language, it's not going to look right. It's not that different conceptually from HTML or LaTeX, which also ignore line breaks in the source. Here is an example of groff source for a manpage: freebsd.org/cgi/cvsweb.cgi/src/bin/ls/… If your input to groff doesn't look something like that, the ouput probably isn't going to look right. –  coneslayer Apr 13 '10 at 21:01
    
Yes, but even plain text have line breaks in place i.e \n, and with the myriad of options for both groff, and family I'm pretty sure it's possible. Also, there is no reason that the two first examples in my first post should look different. There should be no difference in the input that groff recieves. I just put up the second one up there to emulate what I would like to do, print header files on my printer in a decent format. –  Fred Apr 13 '10 at 21:06
1  
I would say it's more in the spirit of the command line to use the right tool for the job. developer.apple.com/Mac/library/documentation/Darwin/Reference/… –  coneslayer Apr 13 '10 at 21:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.