• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2# Convert manual page troff stdin to formatted .txt stdout.
3
4# This file is in the public domain, so clarified as of
5# 2009-05-17 by Arthur David Olson.
6
7# Tell groff not to emit SGR escape sequences (ANSI color escapes).
8GROFF_NO_SGR=1
9export GROFF_NO_SGR
10
11echo ".am TH
12.hy 0
13.na
14..
15.rm }H
16.rm }F" | nroff -man - ${1+"$@"} | perl -ne '
17	binmode STDIN, '\'':encoding(utf8)'\'';
18	binmode STDOUT, '\'':encoding(utf8)'\'';
19	chomp;
20	s/.\010//g;
21	s/\s*$//;
22	if (/^$/) {
23		$sawblank = 1;
24		next;
25	} else {
26		if ($sawblank && $didprint) {
27			print "\n";
28			$sawblank = 0;
29		}
30		print "$_\n";
31		$didprint = 1;
32	}
33'
34