1 |
dpavlin |
3 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
####################################################################### |
4 |
|
|
# |
5 |
|
|
# pod2wiki - A utility to convert Pod documents to Wiki format. |
6 |
|
|
# |
7 |
|
|
# reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org |
8 |
|
|
# |
9 |
|
|
# Documentation after __END__ |
10 |
|
|
# |
11 |
|
|
|
12 |
|
|
use strict; |
13 |
|
|
use Pod::Simple::Wiki; |
14 |
|
|
use Getopt::Long; |
15 |
|
|
use Pod::Usage; |
16 |
|
|
|
17 |
|
|
my $man = 0; |
18 |
|
|
my $help = 0; |
19 |
|
|
my $style = 'wiki'; |
20 |
|
|
my $whine = 1; |
21 |
|
|
my $errata = 1; |
22 |
|
|
my $complain = 0; |
23 |
|
|
|
24 |
|
|
GetOptions( |
25 |
|
|
'help|?' => \$help, |
26 |
|
|
'man' => \$man, |
27 |
|
|
'style=s' => \$style, |
28 |
|
|
'whine!' => \$whine, |
29 |
|
|
'errata!' => \$errata, |
30 |
|
|
'complain!' => \$complain, |
31 |
|
|
) or pod2usage(2); |
32 |
|
|
|
33 |
|
|
pod2usage(1) if $help; |
34 |
|
|
pod2usage(-verbose => 2) if $man; |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
# From the Pod::Usage pod: |
38 |
|
|
pod2usage() if @ARGV == 0 && -t STDIN; |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
my $parser = Pod::Simple::Wiki->new($style); |
42 |
|
|
$parser->no_whining(not $whine); |
43 |
|
|
$parser->no_errata_section(not $errata); |
44 |
|
|
$parser->complain_stderr($complain); |
45 |
|
|
|
46 |
|
|
if (defined $ARGV[0]) { |
47 |
|
|
open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n"; |
48 |
|
|
} else { |
49 |
|
|
*IN = *STDIN; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
if (defined $ARGV[1]) { |
53 |
|
|
open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n"; |
54 |
|
|
$parser->output_fh(*OUT); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
$parser->parse_file(*IN); |
59 |
|
|
|
60 |
|
|
|
61 |
|
|
__END__ |
62 |
|
|
|
63 |
|
|
=head1 NAME |
64 |
|
|
|
65 |
|
|
pod2wiki - A utility to convert Pod documents to Wiki format. |
66 |
|
|
|
67 |
|
|
=head1 SYNOPSIS |
68 |
|
|
|
69 |
|
|
pod2wiki [--style --noerrata --help --man] podfile [outfile] |
70 |
|
|
|
71 |
|
|
Options: |
72 |
|
|
--style wiki style (defaults to wiki. See --help) |
73 |
|
|
--noerrata don't generate a "POD ERRORS" section |
74 |
|
|
--help brief help message |
75 |
|
|
--man full documentation |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
=head1 OPTIONS |
79 |
|
|
|
80 |
|
|
=over 4 |
81 |
|
|
|
82 |
|
|
=item B<podfile> |
83 |
|
|
|
84 |
|
|
The input file that contains the Pod file to be converted. It can also be stdin. |
85 |
|
|
|
86 |
|
|
=item B<outfile> |
87 |
|
|
|
88 |
|
|
The converted output file in wiki format. Defaults to stdout if not specified. |
89 |
|
|
|
90 |
|
|
=item B<--style or -s> |
91 |
|
|
|
92 |
|
|
Sets the wiki style of the output. If no C<style> is specified the program defaults to C<wiki>. The available options are: |
93 |
|
|
|
94 |
|
|
=over 4 |
95 |
|
|
|
96 |
|
|
=item wiki |
97 |
|
|
|
98 |
|
|
This is the original Wiki format as used on Ward Cunningham's Portland repository of Patterns. The formatting rules are given at http://c2.com/cgi/wiki?TextFormattingRules |
99 |
|
|
|
100 |
|
|
=item kwiki |
101 |
|
|
|
102 |
|
|
This is the format as used by Brian Ingerson's CGI::Kwiki: http://search.cpan.org/dist/CGI-Kwiki/ |
103 |
|
|
|
104 |
|
|
=item usemod |
105 |
|
|
|
106 |
|
|
This is the format used by the Usemod wikis. See: http://www.usemod.com/cgi-bin/wiki.pl?WikiFormat |
107 |
|
|
|
108 |
|
|
=item twiki |
109 |
|
|
|
110 |
|
|
This is the format used by TWiki wikis. See: http://www.twiki.org/ |
111 |
|
|
|
112 |
|
|
=item wikipedia or mediawiki |
113 |
|
|
|
114 |
|
|
This is the format used by Wikipedia and MediaWiki wikis. See: http://www.wikipedia.org/ |
115 |
|
|
|
116 |
|
|
=back |
117 |
|
|
|
118 |
|
|
|
119 |
|
|
=item B<--noerrata or -noe> |
120 |
|
|
|
121 |
|
|
Don't generate a "POD ERRORS" section at the end of the document. Equivalent to the C<Pod::Simple::no_errata_section()> method. |
122 |
|
|
|
123 |
|
|
|
124 |
|
|
=item B<--help or -h> |
125 |
|
|
|
126 |
|
|
Print a brief help message and exits. |
127 |
|
|
|
128 |
|
|
|
129 |
|
|
=item B<--man or -m> |
130 |
|
|
|
131 |
|
|
Prints the manual page and exits. |
132 |
|
|
|
133 |
|
|
|
134 |
|
|
=back |
135 |
|
|
|
136 |
|
|
=head1 DESCRIPTION |
137 |
|
|
|
138 |
|
|
This program is used for converting Pod text to Wiki text. |
139 |
|
|
|
140 |
|
|
Pod is Perl's I<Plain Old Documentation> format. See C<man perlpod> or C<perldoc perlpod>. |
141 |
|
|
|
142 |
|
|
A Wiki is a user extensible web site. It uses very simple mark-up that is converted to Html. |
143 |
|
|
|
144 |
|
|
For an introduction to Wikis see: http://c2.com/cgi/wiki?WikiGettingStartedFaq and http://c2.com/cgi/wiki?WikiWikiWebFaq |
145 |
|
|
|
146 |
|
|
=cut |