/usr/bin/textile is in libtext-textile-perl 2.13-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | #!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
use Getopt::Long;
use Text::Textile qw(textile);
my ($is_fullpage, $help, $outfile, $title, $show_version);
GetOptions (
"fullpage" => \$is_fullpage,
"help" => \$help,
"outfile=s" => \$outfile,
"title=s" => \$title,
"version" => \$show_version,
) or die;
$is_fullpage = 1 if defined $title;
if ($show_version) {
print "$Text::Textile::VERSION\n";
exit;
}
################################################################################
my $prog = basename($0);
my $Usage = <<"END";
$prog [-fullpage] [-title "My <b>HTML</b> title"] [-outfile out.html] file.txt [file2.txt ...]
$prog -help
Convert Textile markup text in input file to HTML
Options:
-fullpage Add <html>, <head>, and <body> tags to make a full HTML page
-help Print this help
-outfile ... Send results to a file, rather than to STDOUT
-title "..." Add a <title> (implies -fullpage). Title string can include HTML
perldoc textile for way examples, etc.
END
die $Usage if $help;
main($is_fullpage, $outfile, $title);
exit;
################################################################################
sub main {
my ($is_fullpage, $outfile, $title) = @_;
local $/; # slurp whole file
my $source = <>;
my $textile_text = textile($source);
if ($is_fullpage) {
$textile_text = make_fullpage($textile_text, $title);
}
else {
$textile_text .= "\n"; # add \n for, e.g., 'echo "blah" | textile'
}
if (defined $outfile) {
open my $out_fh, ">", $outfile or die "Can't open outfile $outfile: $!\n";
print $out_fh $textile_text;
close $out_fh;
}
else { # just print to STDOUT
print $textile_text;
}
return;
}
# Top/bottom of HTML page
my ($Pre_Title, $Post_Title, $Post_Body);
BEGIN {
$Pre_Title = <<'ENDPRETITLE';
<html>
<head>
ENDPRETITLE
$Post_Title = <<'ENDPOSTTITLE';
</head>
<body>
ENDPOSTTITLE
$Post_Body = <<'ENDPOSTBODY';
</body>
</html>
ENDPOSTBODY
}
sub make_fullpage {
my ($text_in, $title) = @_; # $title may be undef
my $title_text = defined $title ? "<title>$title</title>\n" : "";
my $text_out = join "",
$Pre_Title,
$title_text,
$Post_Title,
$text_in,
$Post_Body;
return $text_out;
}
__END__
=head1 NAME
textile - Translate Textile markup language to HTML
=head1 SYNOPSIS
# translate a text file to HTML, print to screen
textile file.txt
# translate a snippet of text to HTML
echo "hi there" | textile
# translate a text file, output to a file
textile -outfile out.html file.txt
# translate a text file, output to a legal full HTML file
# (By default, textile doesn't output <html>, <head> and <body> tags)
textile -fullpage -outfile out.html file.txt
# translate a text file, output to a legal full HTML file, add title
# (-title implies -fullpage)
textile -title "My <blink>133t</blink> web page" -outfile out.html file.txt
=head1 DESCRIPTION
This program uses Brad Choate's L<Text::Textile> module to convert
text in the Textile markup language into HTML. For example, it will
convert "_hi_ there" to C<< <p><em>hi</em> there</p> >>. Textile
(developed by Dean Allen of L<http://textism.com> lets you quickly write
simple (or not so simple) text that (a) can be read as is, and (b) turns
into readable HTML.
=head1 AUTHOR
Amir Karger, akarger@cpan.org
Brad Choate built Text::Textile
Dean Allen of Textism.com developed Textile.
=head1 SEE ALSO
L<Text::Textile>, L<http://textism.com>
|