1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#! /usr/bin/perl
# rmanprocess.pl <rman LaTeX2e output>
#
# Example:
# rman -f LaTeX2e foo.man | rmanprocess.pl > foo.tex
#
# Converts a man page to a HMMER User's Guide section.
# Written to operate with PolyglotMan v3.0.5, by Thomas Phelps
# Obtain from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z
#
# - removes document declarations
# - removes See Also and Author sections, if present
# - converts sections to subsections
# - adds a subsection declaration for program name
#
#
# SRE, Mon May 25 11:06:58 1998
while (<>)
{
if (/--/) { s/--/{-}{-}/g; }
if (/^\\documentclass/) {
print "\\setlength{\\sresavei}{\\parindent}\n";
print "\\setlength{\\sresaves}{\\parskip}\n";
next;
}
if (/^\\begin\{document\}/) { next; }
if (/^\s*\\section\{See/ || /^\\end\{document\}/) {
print "\\setlength{\\parindent}{\\sresavei}\n";
print "\\setlength{\\parskip}{\\sresaves}\n";
print "\\newpage";
last;
}
if (/\\begin\{itemize\}/ || /\\end\{itemize\}/) {
s/itemize/wideitem/;
print;
next;
}
if (/^\\section\{Name/) {
while (<>) { # get one-line "foo - a program to do bar"
if (/^(\S+)\s+-\s+(.+)$/) { print "\\subsection{\\texttt{$1} - $2}\n"; }
elsif (/^\\section/) { last; }
}
}
# while ($line = <>) {
# if ($line =~ /\\begin\{itemize\}/) { last; }
# }
# while ($line = <>) { # get item
#
#
# last;
# } elsif ($line =~ /^\\item\s*\[(\S+)\s*-\s*(.+)/) {
# print "\\subsection{\\texttt{$1} - $2}\n";
# last;
# }
# }
# while (<>) {
# if (/\\end\{itemize\}/) { last; }
# }
# next;
if (/^\\section/) {
s/section/subsubsection/;
print;
next;
}
print;
}
|