Debian Codegraph @

bin/text2html

raw
1 #!/usr/bin/perl
2 # -*- cperl -*-
3 use HTML::FromText;
4 # PODNAME: text2html
5 # ABSTRACT: convert plain text to HTML
6
7 my %options, @files;
8
9 my $options_done = 0;
10 while ( $_ = shift @ARGV ) {
11 if ( /^--\w/ && ! $options_done ) {
12 s/^--//;
13 my ($option, $val) = split /=/, $_, 2;
14 $val = 1 unless defined $val;
15 $options{$option} = $val;
16 } elsif ( /^--$/ ) {
17 $options_done = 1;
18 } else {
19 push @files, $_;
20 }
21 }
22
23 @ARGV = @files;
24
25 my $html = text2html
26 do {undef $/; <>},
27 %options;
28
29 $html .= "\n" unless $html =~ /\n$/;
30
31 print $html;
32
33 exit 0;
34
35 __END__
36
37 =pod
38
39 =head1 NAME
40
41 text2html - convert plain text to HTML
42
43 =head1 VERSION
44
45 version 2.07
46
47 =head1 SYNOPSIS
48
49 B<text2html [options...]> [file ...]
50
51 =head1 DESCRIPTION
52
53 The C<text2html> utility converts text to HTML. Text can come from
54 standard input or files listed on the command line.
55
56 The available options are outlined in L<HTML::FromText>. The option
57 syntax is slightly different. Options are prefixed with two dashes
58 (C<-->) and may have an option value following an equals sign (C<=>).
59 The default value is on (<1>).
60
61 =head1 EXAMPLES
62
63 Convert the C<README> file using C<paras> and C<blockcode>.
64
65 text2html --paras --blockcode README
66
67 Convert a file called C<--stupid-name>.
68
69 text2html --paras -- --stupid-name
70
71 Convert text on standard input.
72
73 text2html --paras --urls --email --bold --underline
74
75 Convert text on standard input but turn off C<metachars>.
76
77 text2html --metachars=0 --lines
78
79 =head1 DIAGNOSTICS
80
81 The C<text2html> utility exits 0 on success, and >0 if an error occurs.
82
83 =head1 SEE ALSO
84
85 L<perl(1)>, L<HTML::FromText(3)>.
86
87 =head1 AUTHORS
88
89 =over 4
90
91 =item *
92
93 Ricardo SIGNES <[email protected]>
94
95 =item *
96
97 Casey West <[email protected]>
98
99 =item *
100
101 Gareth Rees <[email protected]>
102
103 =back
104
105 =head1 COPYRIGHT AND LICENSE
106
107 This software is copyright (c) 2003 by Casey West.
108
109 This is free software; you can redistribute it and/or modify it under
110 the same terms as the Perl 5 programming language system itself.
111
112 =cut