File: text2html

package info (click to toggle)
libhtml-fromtext-perl 2.07-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 430; makefile: 2
file content (112 lines) | stat: -rwxr-xr-x 2,035 bytes parent folder | download | duplicates (3)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/perl
# -*- cperl -*-
use HTML::FromText;
# PODNAME:  text2html
# ABSTRACT: convert plain text to HTML

my %options, @files;

my $options_done = 0;
while ( $_ = shift @ARGV ) {
    if ( /^--\w/ && ! $options_done ) {
        s/^--//;
        my ($option, $val) = split /=/, $_, 2;
        $val = 1 unless defined $val;
        $options{$option} = $val;
    } elsif ( /^--$/ ) {
        $options_done = 1;
    } else {
        push @files, $_;
    }
}

@ARGV = @files;

my $html = text2html
  do {undef $/; <>},
  %options;

$html .= "\n" unless $html =~ /\n$/;

print $html;

exit 0;

__END__

=pod

=head1 NAME

text2html - convert plain text to HTML

=head1 VERSION

version 2.07

=head1 SYNOPSIS

B<text2html [options...]> [file ...]

=head1 DESCRIPTION

The C<text2html> utility converts text to HTML. Text can come from
standard input or files listed on the command line.

The available options are outlined in L<HTML::FromText>. The option
syntax is slightly different. Options are prefixed with two dashes
(C<-->) and may have an option value following an equals sign (C<=>).
The default value is on (<1>).

=head1 EXAMPLES

Convert the C<README> file using C<paras> and C<blockcode>.

  text2html --paras --blockcode README

Convert a file called C<--stupid-name>.

  text2html --paras -- --stupid-name

Convert text on standard input.

  text2html --paras --urls --email --bold --underline

Convert text on standard input but turn off C<metachars>.

  text2html --metachars=0 --lines

=head1 DIAGNOSTICS

The C<text2html> utility exits 0 on success, and >0 if an error occurs.

=head1 SEE ALSO

L<perl(1)>, L<HTML::FromText(3)>.

=head1 AUTHORS

=over 4

=item *

Ricardo SIGNES <rjbs@cpan.org>

=item *

Casey West <casey@geeknest.com>

=item *

Gareth Rees <garethr@cre.canon.co.uk>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2003 by Casey West.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut