Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!agate!bionet!parc!mdixon From: mdixon@parc.xerox.com (Mike Dixon) Newsgroups: comp.sys.next Subject: nroff output to rtf Message-ID: Date: 2 Apr 91 18:47:58 GMT Sender: news@parc.xerox.com Distribution: comp Organization: Xerox PARC Lines: 63 when you look at man pages with the Librarian, it (sometimes) manages to show them with reasonable formatting. sometimes it doesn't, and sometimes you want to look at them with something other than Librarian, so here's a little hack to convert nroff output to rtf. a) it's in perl. it would probably be trivial to rewrite in C, should you feel the need. b) it's the first perl program i ever wrote, so i'm sure it could be better, but it works pretty well. c) this version makes an rtf file with 12pt ohlfs, converting nroff underlining to rtf underlining. it's trivial to use a different font (e.g. the Librarian uses helvetica) or a different attribute for underlining (e.g. Librarian uses italics). if you want to do this and can't figure out the code, send me a message. to use it, put it somewhere like /usr/local/bin/tty2rtf, and e.g. tty2rtf ) { chop; if ($_ ne "") { while (/(_\008.)+/) { do fix($`,"\n\\ul "); $bld = $&; $_ = $'; $bld =~ s/_\008//g; do fix($bld,"\n\\ul0 "); } do fix($_,"\\\n"); $skip = 0; } elsif (! $skip) { print "\\\n"; $skip = 1; } } print "}\n"; sub fix { local($tmp,$tail) = @_; $tmp =~ s/\\/\\\\/g; $tmp =~ s/\{/\\\{/g; $tmp =~ s/\}/\\\}/g; print $tmp,$tail; } -- .mike.