$DEF_INDENT = 4;
$indent = $DEF_INDENT;
$needspace = 0;
+$begun = "";
open(IN, $file) || die "Couldn't open $file: $!";
next unless /^=/;
$cutting = 0;
}
+ if ($begun) {
+ if (/^=end\s+$begun/) {
+ $begun = "";
+ }
+ elsif ($begun eq "text") {
+ print STDOUT $_;
+ }
+ next;
+ }
1 while s{^(.*?)(\t+)(.*)$}{
$1
. (' ' x (length($2) * 8 - length($1) % 8))
next;
}
+ if (/^=for\s+(\S+)\s*/s) {
+ if ($1 eq "text") {
+ print STDOUT $',"";
+ } else {
+ # ignore unknown for
+ }
+ next;
+ }
+ elsif (/^=begin\s+(\S+)\s*/s) {
+ $begun = $1;
+ if ($1 eq "text") {
+ print STDOUT $'."";
+ }
+ next;
+ }
+
sub prepare_for_output {
s/\s*$/\n/;
&do_hdr();
$cutting = 1;
+$begun = "";
while (<POD>) {
if ($cutting) {
next unless /^=/;
$cutting = 0;
}
+ if ($begun) {
+ if (/^=end\s+$begun/) {
+ $begun = "";
+ }
+ elsif ($begun =~ /^(tex|latex)$/) {
+ print LATEX $_;
+ }
+ next;
+ }
chop;
length || (print LATEX "\n") && next;
next;
}
+ if (/^=for\s+(\S+)\s*/s) {
+ if ($1 eq "tex" or $1 eq "latex") {
+ print LATEX $',"\n";
+ } else {
+ # ignore unknown for
+ }
+ next;
+ }
+ elsif (/^=begin\s+(\S+)\s*/s) {
+ $begun = $1;
+ if ($1 eq "tex" or $1 eq "latex") {
+ print LATEX $'."\n";
+ }
+ next;
+ }
+
# preserve '=item' line with pod quotes as they are.
if (/^=item/) {
($bareitem = $_) =~ s/^=item\s*//;
$indent = 0;
+$begun = "";
+
while (<>) {
if ($cutting) {
next unless /^=/;
$cutting = 0;
}
+ if ($begun) {
+ if (/^=end\s+$begun/) {
+ $begun = "";
+ }
+ elsif ($begun =~ /^(roff|man)$/) {
+ print STDOUT $_;
+ }
+ next;
+ }
chomp;
# Translate verbatim paragraph
$verbatim = 0;
+ if (/^=for\s+(\S+)\s*/s) {
+ if ($1 eq "man" or $1 eq "roff") {
+ print STDOUT $',"\n\n";
+ } else {
+ # ignore unknown for
+ }
+ next;
+ }
+ elsif (/^=begin\s+(\S+)\s*/s) {
+ $begun = $1;
+ if ($1 eq "man" or $1 eq "roff") {
+ print STDOUT $'."\n\n";
+ }
+ next;
+ }
+
# check for things that'll hosed our noremap scheme; affects $_
init_noremap();