3 # xmltoman - simple xml to man converter
4 # Copyright (C) 2000-2002 Oliver Kurth <oku@masqmail.cx>
5 # 2003 Lennart Poettering <mzkzygbzna@0pointer.de>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 s/^\s*//gm if (!$break_req);
51 s/^\s$//gm if (!$space);
59 if ($stack_n == 0 or $a ne $stack[$stack_n-1]) {
60 out
("\\fB") if $a =~ /^bold$/;
61 out
("\\fI") if $a =~ /^italic$/;
64 $stack[$stack_n++] = $a;
74 $a = $stack[$stack_n-1];
75 out
("\\fB") if $a =~ /^bold$/;
76 out
("\\fI") if $a =~ /^italic$/;
93 print "\n" if ($break_req);
94 print ".TH " . $attr{name
} . " " . $attr{section
} . " User Manuals\n";
96 print $attr{name
} . " \\- " . $attr{desc
} . "\n";
98 } elsif (/^synopsis$/) {
100 print "\n" if ($break_req);
101 print ".SH SYNOPSIS\n";
105 } elsif (/^description$/) {
107 print "\n" if ($break_req);
108 print ".SH DESCRIPTION\n";
111 } elsif (/^options$/) {
113 print "\n" if ($break_req);
114 print ".SH OPTIONS\n";
117 } elsif (/^seealso$/) {
119 print "\n" if ($break_req);
120 print ".SH SEE ALSO\n";
123 } elsif (/^section$/) {
125 print "\n" if ($break_req);
126 print ".SH ".uc($attr{name
})."\n";
127 $section = $attr{name
};
129 } elsif (/^option$/) {
131 print "\n" if ($break_req);
134 } elsif (/^p$/ or /^cmd$/) {
136 print "\n" if ($para);
138 } elsif (/^optdesc$/) {
141 } elsif (/^arg$/ or /^file$/) {
143 stack_push
("italic");
147 } elsif (/^manref$/) {
150 out
($attr{name
} ."(" . $attr{section
} . ")");
171 if (/^description$/ or /^options$/ or /^section$/ or /^seealso$/) {
173 } elsif (/^p$/ or /^cmd$/) {
175 print "\n" if ($break_req);
178 } elsif (/^synopsis$/) {
181 } elsif (/^opt$/ or /^arg$/ or /^file$/) {
184 } elsif (/^manpage$/) {
186 print "\n" if $break_req;
188 } elsif (/^optdesc$/ or /^cmd$/ or /^option$/) {
207 print STDERR
"You need to specify a file to parse\n";
211 my $parser = new XML
::Parser
(Handlers
=> {
212 Start
=> \
&handle_start
,
214 Char
=> \
&handle_char
});
216 $parser->parsefile($file, ProtocolEncoding
=> 'ISO-8859-1');